Menu

#1202 Response body not parsed for OK 200 if If-Modified-Since matches Last-Modified

closed-rejected
None
5
2014-08-28
2013-03-04
Niko Sams
No

For some reason fetching the url with lastmodified options doesn't work
correctly. The server returns a 200 OK but the response doesn't include the
body.

to reproduce start the following php script:

<?php 
$sock = socket_create_listen(1234); 
socket_getsockname($sock, $addr, $port); 
print "Server Listening on $addr:$port\n"; 
while($c = socket_accept($sock)) { 
    socket_getpeername($c, $raddr, $rport); 
    print "Received Connection from $raddr:$rport\n";
    $buf = '';
    do {
        $l = socket_read($c, 1024);
        $buf .= $l;
    } while (substr($buf, -4) != "\r\n\r\n");
    echo $buf."\n";
    $out = "HTTP/1.1 200 OK
Content-Type: text/plain
Last-Modified: Mon, 25 Feb 2013 13:35:56 GMT

test

";
$out = str_replace("\n", "\r\n", $out);
echo $out;
socket_write($c, $out, strlen($out));
socket_close($c);
} 
socket_close($sock); 
?>

and try to fetch:
curl localhost:1234 -v -z "Mon, 25 Feb 2013 13:35:56 GMT"

Expected behavior:
body ("test") should be included in response

Actual behavior:
body is not included in response

Downstream bug: https://bugs.php.net/bug.php?id=64298

Discussion

  • Daniel Stenberg

    Daniel Stenberg - 2013-03-04

    If the server doesn't respond with a body when curl sends a request, how is that a curl bug?

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-03-04
    • assigned_to: Daniel Stenberg
    • milestone: -->
     
  • Niko Sams

    Niko Sams - 2013-03-05

    The server is responding with a body. ("test")

     
  • Dan Fandrich

    Dan Fandrich - 2013-03-05

    This looks almost identical to test case 77. Can you find out what the difference is any what that works and not this? Test 77 has a Content-Length: whereas this test doesn't--does that make a difference?

     
  • Niko Sams

    Niko Sams - 2013-03-05

    Including a Content-Length doesn't make a difference:

    curl localhost:1234 -v -z "Mon, 25 Feb 2013 13:35:56 GMT"
    
    * About to connect() to localhost port 1234 (#0)
    *   Trying 192.168.0.128...
    * Connected to localhost (127.0.0.1) port 1234 (#0)
    > GET / HTTP/1.1
    > User-Agent: curl/7.29.0
    > Host: localhost:1234
    > Accept: */*
    > If-Modified-Since: Mon, 25 Feb 2013 13:35:56 GMT
    > 
    < HTTP/1.1 200 OK
    < Content-Type: text/plain
    < Last-Modified: Mon, 25 Feb 2013 13:35:56 GMT
    < Content-Length: 8
    < 
    * The requested document is not new enough
    * Closing connection 0
    
     
  • Daniel Stenberg

    Daniel Stenberg - 2013-03-05

    Ok, so you're asking curl to deliver data if it has been modified since time T. The server says the data was modified at time T. curl doesn't return any data according to your wish.

    Do I understand you correctly that you don't think curl should do this magic by itself when the server responded with a 200? Or do I misunderstand?

     
  • Niko Sams

    Niko Sams - 2013-03-05

    Yes.

    Because: my application needs to know if the response should be considered as OK or not modified. Currently this is done by checking the response code. If curl does "this magic" I need a way to know that it did - that would be perfectly fine too.

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-04-01

    You're basically asking for a modified behavior, not a bug fix. What are you proposing (lib)curl should do, exactly?

     
  • Niko Sams

    Niko Sams - 2013-04-02

    I don't have enough knowledge about libcurl to comment on what/how this should be done.

    (1) Possible solution (that would modify behavior): If body is ignored return 304 (although the server responded 200)

    (2) Naive solution: Some (new) property that gets set when this happens that can be queried

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-05-21
    • status: open --> closed-rejected
    • Group: --> not_used
     
  • Daniel Stenberg

    Daniel Stenberg - 2013-05-21

    Sorry, as this is not a bug I decided to close this bug report. If you want to pursue the idea of changing the behavior in some way, or providing an alternative information you can use, then please bring it to a suitable mailing list.

    Thanks for your interest and help in improving curl!

     
MongoDB Logo MongoDB