ocaml-cohttp
                                
                                 ocaml-cohttp copied to clipboard
                                
                                    ocaml-cohttp copied to clipboard
                            
                            
                            
                        callv: graceful handling of remote close
Hi,
now my problem is about a connection shutdown initiated by the remote server during a pipelined connection (for example because it imposes a limit on requests per connection). This shutdown is only noticed after the next request is already sent to the wire and read_response tries to read from the in channel. It will then fail with Failure "Client connection was closed". This is especially annoying for non-idempotent requests, because the user won't know whether the request has been processed by the server.
It would be better to detect the shutdown as soon as the tcp FIN packet is received and then either attempt a reconnect or fail when the next request is queued.
@madroach is there a particular reason why you need pipelining? Pipelining is mostly a misfeature avoided by most http clients. I'd suggest you to do the same here.
Hi, thanks for your reply. I chose the wrong wording. The problem is not about pipelining, but only about connection keep-alive. During pipelining, which is currently not supported, it won't occur.
What is missing is a reader that can handle EOF while there is no request on the wire.
I do already have a working pipelining implementation with connection cache sitting around since 2020, which solves this and supports pipelining, which in my mind has legitimate applications. It just needs a bit polishing, then I'll submit a pull request.
fixed by #853