curl-library
Re: http keep-alive when mongoose + libcurl
Date: Fri, 24 Dec 2010 00:38:22 -0800
On Fri, Dec 24, 2010 at 04:05:27PM +0800, Dannoy Lee wrote:
> Hi,
> Dan,thank you for answer me so quickly.Here I try to make the things more
> specific.
> First, I try persistant.c(I modified it a bit , see attachment) example with
> my modified mongoose http server without authentication and following location.
> And my persistant runs well.
> Second, I add authentication and "Location" header to response client
> request, my persistant hangs.
That's because the server sends an incomplete response, and libcurl
(rightly) waits for it to complete. Take a look at the log:
> And here is the BAD log:
>
> [xxx_at_localhost bad]$ ./persist
> * About to connect() to localhost port 8081 (#0)
> * Trying 127.0.0.1... * connected
> * Connected to localhost (127.0.0.1) port 8081 (#0)
> * Server auth using Digest with user 'lijin'
> > GET /my HTTP/1.1
> Host: localhost:8081
> Accept: */*
>
> < HTTP/1.1 401 Unauthorized
> HTTP/1.1 401 Unauthorized
> < WWW-Authenticate: Digest qop="auth", realm="my_at_example.com", nonce=
> "1293176855"
> WWW-Authenticate: Digest qop="auth", realm="my_at_example.com", nonce="1293176855"
> * no chunk, no close, no size. Assume close to signal end
As the debug message helpfully points out, the HTTP response does not
include a chunk header, nor a content length, nor a connection close
indication. Since the server provides no way to tell the end of the
response, libcurl assumes a Connection:close and simply waits for the socket
close. As far as it's concerned, the server may be about to send a
nicely formatted error message that the application wishes to receive,
so there is no other choice but to wait for it. Needless to say, that
never comes.
You need to fix the server so it sends a correct response.
>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-24