Re:Patch: strange behaviour with 304 not modified and HTTP/1.1 persistant connections..
Date: Tue, 01 May 2001 13:19:12 +1000
Well - it seems I was right about the content length thing..
This seems to fix it:
RCS file: /cvsroot/curl/lib/transfer.c,v
retrieving revision 1.36
diff -u -r1.36 transfer.c
--- transfer.c 2001/04/27 18:03:44 1.36
+++ transfer.c 2001/05/01 03:16:51
@@ -413,6 +413,14 @@
we get one of those fancy headers that tell us the
server keeps it open for us! */
conn->bits.close = TRUE;
+ if (httpcode == 304)
+ /* (quote from RFC2616, section 10.3.5):
+ * The 304 response MUST NOT contain a
+ * message-body, and thus is always
+ * terminated by the first empty line
+ * after the header fields.
header = FALSE; /* this is not a header line */
I'd appreciate it if you would review this and apply it the CVS....
Cris Bailiff wrote:
> I'm having a weird problem with libcurl and fetching content with
> 'If-Modified-Since' when the server supports http/1.1 (and therefore keepalives).
> When libcurl connects, and makes a request, it gets the 304 status code and the
> headers correctly, but doesn't return from the request until the server at the
> other end times out and closes the connection. There is no 'content-length' in
> the 304 response, but the servers I've tried don't return any body using
> 'transfer-encoding: chunked' either, so libcurl seems to just sit and wait for a
> body that isn't coming until the server closes the connection.
> I'm not sure if its in the RFC's that 304 never has a body, and therefore there's
> an implicit 'content-length: 0' curl should apply?
> Its trivially reproducible through the command line interface:
> bash$ curl -z 'Wed, 18 Apr 2001 06:57:12 GMT' -v -i
> * Connected to webser.awayweb.com (184.108.40.206)
> > GET /images/bg-top.jpg HTTP/1.1
> User-Agent: curl/7.7.2 (i386-redhat-linux-gnu) libcurl 7.7.2 (SSL 0.9.5)
> Host: www.awayweb.com
> Pragma: no-cache
> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
> If-Modified-Since: Wed, 18 Apr 2001 06:57:12 GMT
> HTTP/1.1 304 Not Modified
> Date: Tue, 01 May 2001 01:27:42 GMT
> Server: Apache/1.3.12 (Red Hat/Linux)
> ETag: "13324-3259-3adbe948"
> At this point, curl just hangs, until the server closes. I would have thought it
> should return immediately, once the 304 code and headers are received.
> Its nearly midnight where I am right now, so I don't think I'll be digging into
> the C code for the next 12 hours or so, but if you have any suggestions (or a
> fix...), that would be good..
> BTW - I've tried this with 7.7.1, 7.7.2 and the current (as of a couple of hours
> ago) CVS version - same results...
> Cris Bailiff
Received on 2001-05-01