-
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
6 changed files
with
85 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version=0.24.1 | ||
version=0.21.0 | ||
profile=conventional | ||
break-infix=fit-or-vertical | ||
parse-docstrings=true |
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,38 @@ | ||
open Eio | ||
open Cohttp_eio | ||
|
||
let get () = | ||
Eio_main.run @@ fun env -> | ||
Switch.run @@ fun sw -> | ||
let res = | ||
Client.get | ||
~headers:(Http.Header.of_list [ ("Accept", "application/json") ]) | ||
env sw | ||
(`Tcp (Eio.Net.Ipaddr.V4.loopback, 8080)) | ||
(Uri.of_string "/get") | ||
in | ||
match Client.read_fixed res with Some s -> print_string s | None -> () | ||
|
||
let post () = | ||
Eio_main.run @@ fun env -> | ||
Switch.run @@ fun sw -> | ||
let content = "hello world!" in | ||
let content_length = String.length content |> string_of_int in | ||
let res = | ||
Client.post | ||
~headers: | ||
(Http.Header.of_list | ||
[ | ||
("Accept", "application/json"); ("Content-Length", content_length); | ||
]) | ||
~body:(Body.Fixed content) env sw | ||
(`Tcp (Eio.Net.Ipaddr.V4.loopback, 8080)) | ||
(Uri.of_string "/post") | ||
in | ||
match Client.read_fixed res with Some s -> print_string s | None -> () | ||
|
||
let () = | ||
match Sys.argv.(1) with | ||
| "get" -> get () | ||
| "post" -> post () | ||
| _ -> print_string "Usage: test-client [get|post]" |
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,25 @@ | ||
Test Client.get | ||
|
||
$ test-server & | ||
$ running_pid=$! | ||
$ test-client get | ||
meth: GET | ||
resource: /get | ||
version: HTTP/1.1 | ||
headers: Header { Accept = "application/json" } | ||
|
||
$ kill ${running_pid} | ||
|
||
Test Client.post | ||
|
||
$ test-server & | ||
$ running_pid=$! | ||
$ test-client post | ||
meth: POST | ||
resource: /post | ||
version: HTTP/1.1 | ||
headers: Header { Accept = "application/json"; Content-Length = "12" } | ||
|
||
hello world! | ||
|
||
$ kill ${running_pid} |
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