Comments (2)
I don't see that on my machine. Here's a self-contained test-case that includes a test client:
open Eio.Std
open Cohttp
let addr = `Tcp (Eio.Net.Ipaddr.V4.any, 8080)
let header = "POST / HTTP/1.1\r\n\
Host: 127.0.0.1:8080\r\n\
User-Agent: curl/7.88.1\r\n\
Accept: */*\r\n\
Content-Length: 3\r\n\
Content-Type: application/x-www-form-urlencoded\r\n\
\r\n\
"
let run_client net =
Switch.run @@ fun sw ->
let conn = Eio.Net.connect ~sw net addr in
Eio.Flow.write conn [Cstruct.of_string header];
traceln "waiting...";
Eio_unix.sleep 0.8;
traceln "done";
Eio.Flow.write conn [Cstruct.of_string "oo"];
Eio.Flow.shutdown conn `Send;
traceln "Got: %S" (Eio.Flow.read_all conn)
let () =
let handler _env _conn _req body =
let body = Eio.Flow.read_all body in
Printf.printf "Body read with length: %i\n%!" (String.length body);
( Http.Response.make
~status:`OK
~headers:(Header.of_list [])
(),
Eio.Flow.string_source "" )
in
Eio_main.run @@ fun env ->
Eio.Switch.run @@ fun sw ->
let socket = Eio.Net.listen env#net ~sw ~backlog:128 ~reuse_addr:true addr
and server = Cohttp_eio.Server.make ~callback:(handler env) () in
let log_warning ex = Printf.eprintf "%s%!" (Printexc.to_string ex) in
Fiber.both
(fun () -> Cohttp_eio.Server.run socket server ~on_error:log_warning)
(fun () -> run_client env#net)
Running that, I get:
+waiting...
+done
Body read with length: 2
+Got: "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\n\r\n0\r\n\r\n"
Does it work for you?
(I'm using cohttp-eio 6.0.0~beta2)
from ocaml-cohttp.
I don't have a setup to test anymore. I'll close the issue for now, if I ever see it again, I will reopen it and run the repro.
from ocaml-cohttp.
Related Issues (20)
- High latency with Linux clients - or "It's always the Nagle's Algorithm" HOT 3
- Cohttp_eio.Server.run is hardcoded to listen on loopback HOT 2
- Cohttp-eio: response body not flushed? HOT 2
- cohttp-eio: "large" chunked-response → exception Eio.Io Unix_error (Invalid argument, "writev", "") HOT 4
- cohttp-eio: confusing use of the `~sw` argument HOT 1
- cohttp 5.3.0: `Cookie.Set_cookie_hdr.extract` only work with lower case `set-cookie` and not uppercase `Set-Cookie` HOT 2
- Incompatibility with cohttp-lwt Server module IO HOT 3
- Supporting CONNECT requests.
- Add connection reset tests to cohttp-eio
- http library name HOT 2
- cohttp-curl swallows errors HOT 3
- Parsing of malformed headers fails silently
- `header_io.ml`''s `parse` doesn't support multi-line "folded" headers HOT 1
- cohttp_curl: First HTTP header is prepended to output HOT 1
- Cohttp-lwt, Server: How should we now close `Expert response_action? HOT 2
- Please backport to v4 support for cmdliner >= 1.2.0 HOT 7
- Bad GET request when host is an IPv6 litteral results in 400 bad Request HOT 2
- Make response type abstract
- SSL read() error while reading response from a POST request HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ocaml-cohttp.