|
Posted by Bill Hoffman on 10/20/52 11:16
On May 18, 2005, at 4:10 PM, Jared Williams wrote:
> Sure the server is checking if modified since headers?
I'm capturing the response headers from the remote server, so I can
see that.
> Just tried a bit of code here and it seems to be working as
> expected (5.0.4 Win32)
1) I made an initial mistake by running my PHP script(s) from the
command line and not from a server.
2) but now when running my PHP script(s) from a server I see that:
file_get_contents() with a conditional get in a stream context works
as expected; that is, the remote server returns a 304 not modified
HTTP response header only. (if doing this with file_get_contents(),
then the libxml_set_streams_context() function call is of course
irrelevant).
DOMDocument::load() with a conditional get in a stream context set
via libxml_set_streams_context() shows odd results; that is, the
remote server returns a 304 not modified in the HTTP response header,
but also returns the file contents as well (!!??).
That's a bit baffling -- a server shouldn't do that, since the 304
response header ends with "connection: close", so I don't know how or
why the file contents are being captured too. I would think a 304
response header means that the request header was properly
interpreted and nothing but a header would be returned. Hard to know
if the problem is on my end or on the remote server side. I note also
that stream contexts send only as HTTP/1.0, and the remote server is
returning HTTP/1.1, and I just don't know if that's a possible factor
in this or not.
Anyhow, I have a workable solution which is sort of ok -- use
file_get_contents() with a conditional get in a stream context to
fetch a remote file on an "if-modified-since" basis, then stuff the
string result into a new DOMDocument() object and have at it that way.
But of course I'm puzzled as to why libxml_set_streams_context() is
doing what it's doing, and it would be nice to know how to get it to
work if it can and should work elsewhere for others.
Thanks for a helpful reply.
Navigation:
[Reply to this message]
|