php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9846 fopen() fails and gives Error 0 on NoContent URLs
Submitted: 2001-03-19 16:56 UTC Modified: 2001-12-15 08:29 UTC
From: bloch at incrementalimages dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.0.4pl1 OS: linux,irix,tru64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bloch at incrementalimages dot com
New email:
PHP Version: OS:

 

 [2001-03-19 16:56 UTC] bloch at incrementalimages dot com
This bug might belong in the URL-related section.
I believe it to be a generic problem.

If you fopen() an URL
that returns with an HTTP Header of NoContent (204),
fopen() will fail with Error 0.

Failure would be ok if there was a specific error
code for NoContent URLs.  Either that or returning
a handle that was already at eof would suffice.
As it is now, there's no way to tell the difference
between a bad (NotFound) URL and a NoContent URL.

Work-around it to use cURL to a temporary file
and check the HTTP_CODE with the undocumented
curl_getinfo() function.  Of course, it seems
a little weird to require the temporary file 
for a NoContent URL.  But it works fine.

-Eric Bloch
bloch@incrementalimages.com

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-29 02:35 UTC] sniper@php.net
Taken from #9847, these are basically the same problem:

    When fopen()-ing an URL that responds
    with an HTTP 403 Forbidden, fopen()
    fails with an Error 0.   There is no
    way to distinguish this error from
    a 'Not Found' type of error.

---


 [2001-11-23 18:03 UTC] venaas@php.net
Doesn't the contents of $http_response_header tell you
what you need? $http_response_header should be an array
of the HTTP response fopen() got
 [2001-12-15 08:29 UTC] sander@php.net
No feedback. Closing.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 15:01:31 2025 UTC