-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
62 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
open Cohttp_eio | ||
|
||
let length = 2053 | ||
let text = String.make length 'a' | ||
let headers = Cohttp.Header.of_list [ ("content-length", Int.to_string length) ] | ||
|
||
let server_callback _conn _req _body = | ||
Server.respond_string ~headers ~status:`OK ~body:text () | ||
|
||
|
||
let () = | ||
let port = ref 8080 in | ||
Arg.parse | ||
[ ("-p", Arg.Set_int port, " Listening port number(8080 by default)") ] | ||
ignore "An HTTP/1.1 server"; | ||
Eio_main.run @@ fun env -> | ||
Eio.Switch.run @@ fun sw -> | ||
let socket = | ||
Eio.Net.listen env#net ~sw ~backlog:11_000 ~reuse_addr:true | ||
(`Tcp (Eio.Net.Ipaddr.V4.loopback, !port)) | ||
and server = Cohttp_eio.Server.make ~callback:server_callback () in | ||
Cohttp_eio.Server.run socket server ~on_error:raise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters