cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re:Patch: strange behaviour with 304 not modified and HTTP/1.1 persistant connections..

From: Cris Bailiff <c.bailiff_at_awayweb.com>
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:

Index: transfer.c
===================================================================
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.
+ */
+ conn->size=0;
                 }
                 else {
                   header = FALSE; /* this is not a header line */

---------

Daniel,
        I'd appreciate it if you would review this and apply it the CVS....

Thanks

Cris

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
> http://www.awayweb.com/images/bg-top.jpg
> * Connected to webser.awayweb.com (203.16.200.27)
> > 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...
>
> Cheers,
>
> Cris Bailiff
> c.bailiff_at_awayweb.com
Received on 2001-05-01