RE: libxml_set_streams_context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

> -----Original Message-----
> From: Bill Hoffman [mailto:xbhoff@xxxxxxx] 
> Sent: 19 May 2005 00:46
> To: php-general@xxxxxxxxxxxxx
> Subject: Re:  libxml_set_streams_context
> 
> 
> 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.

Warning: DOMDocument::load(http://localhost/test.php) [function.load]: failed to open stream: HTTP request failed! HTTP/1.1 304
Undescribed in C:\Inetpub\evildocs\www\load.php on line 12
<?xml version="1.0"?> <refentry id="function.mcal-next-recurrence"> <refnamediv> <refname>mcal_next_recurrence</refname>
<refpurpose>Returns the next recurrence of the event</refpurpose> 

Heh, yes indeed most baffling... Libxml must be performing some sort of cacheing, I guess. Doesn't appear to be requesting twice
(once with the if-modified-since header, and again without atleast)

> 
> 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.
> 
> --
> PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux