Re: How does early error response detection work?
Date: Sat, 23 May 2020 22:57:09 +0200 (CEST)
On Sat, 23 May 2020, Osipov, Michael via curl-users wrote:
> I am currently trying to understand how curl via libcurl detects an early
> error respone (401) on a POST request with a large request body:
I knows this because it gets the response back with that error *before* it has
sent the entire request body. Can you do this any other way?
> I read the source code (rewind and auth) and ran curl through truss. As far
> as I understand curl works with non-blocking I/O. It sends the headers,
> reads from socket and then sends the first block of data (64 KiB), waits
> with a poll for the socket, send the next chuck, receives a EAGAIN (ERR#35
> on BSD), polls again and tries to read from the socket and notices that an
> error response has been transmitted, all FDs are closed and the application
> Hopefully this is properly understood from my side.
Your description depends on your specific circumstances. curl will send as
much as possible of the headers and body until it gets EAGAIN back (or they
were all sent off) and then continue sending more when it can.
> Since all runs in the same thread, I did not fully understand the
> synchronization between read() and write(). Does the EAGAIN on write() cause
> the read() on the socket or rather after a write() happens a read(), sets
> some flags and the write() picks them up and notices that any further
> write()s won't be fruitful?
Reading and writing are handled separately and independently. EAGAIN on send()
will make it wait until it can write again until it retries and the same thing
-- / daniel.haxx.se | Commercial curl support up to 24x7 is available! | Private help, bug fixes, support, ports, new features | https://www.wolfssl.com/contact/ ----------------------------------------------------------- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users Etiquette: https://curl.haxx.se/mail/etiquette.htmlReceived on 2020-05-23