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
If the server doesn't respond with a body when curl sends a request, how is that a curl bug?
The server is responding with a body. ("test")
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?
Including a Content-Length doesn't make a difference:
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?
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.
You're basically asking for a modified behavior, not a bug fix. What are you proposing (lib)curl should do, exactly?
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
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!