|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2003-05-21 11:23 UTC] scoop at freshmeat dot net
 When using file() or other streams functions supporting the use of URIs as their parameter the function behaves incorrectly when encountering HTTP Status Code 202. It'd be useful to return the accessed document instead of returning nothing at all and issuing a warning since the document body is likely to include a reason why status code 202 is being returned (as suggested by the RFC). Would it be possible to change that behaviour? Thanks. Example: Warning: file(http://games.slashdot.org/games.rdf) [http://www.php.net/function.file]: failed to create stream: HTTP request failed! HTTP/1.1 202 Accepted Reference: The HTTP RFC 10.2.3 202 Accepted The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. There is no facility for re-sending a status code from an asynchronous operation such as this. The 202 response is intentionally non-committal. Its purpose is to allow a server to accept a request for some other process (perhaps a batch-oriented process that is only run once per day) without requiring that the user agent's connection to the server persist until the process is completed. The entity returned with this response SHOULD include an indication of the request's current status and either a pointer to a status monitor or some estimate of when the user can expect the request to be fulfilled. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 02:00:02 2025 UTC | 
We won't change fopen() like this, as the semantics of fopen("http://") are that it returns the resource you requested, not an explanation of why it didn't come back ;) In your example, it sounds like you are expecting an XML document as the content; what happens when your XML parser falls over the error text? Remember that fopen() sets $http_response_header in the local scope to be the contents of the headers returned by the remote server; you might find this useful. What you can do instead of using fopen() either use the curl extension or use fsockopen() to make the http request yourself. We have some plans for an "easy" streams based http_request() function in PHP5, but nothing definite yet.