php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #14814 Strange error message on gzopen and ftp:// URL
Submitted: 2002-01-02 20:37 UTC Modified: 2002-04-06 10:18 UTC
From: dubious at 2xtreme dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.1.1 OS: Linux (2.4.17)
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: dubious at 2xtreme dot net
New email:
PHP Version: OS:

 

 [2002-01-02 20:37 UTC] dubious at 2xtreme dot net
It's not clear from the manual whether or not gzopen is 
SUPPOSED to work with http:// and ftp:// URL's, but I get 
the impression the answer is "not yet".  (The 
documentation in the manual IMPLIES that it the 
filehandle-like functions should work with the exception 
of socket functions, but the user commentary below the 
gzopen entry implies that it doesn't work for http:// 
URL's either...)

However, when attempting to gzopen a .gz file from an FTP 
site, the error message returned is very strange:
-----------------------------------------------------
<b>Warning</b>:  
gzopen("ftp://ftp.ncbi.nih.gov/genbank/gbpln3.seq.gz","r") 
- Success in <b>projects/phpdna/get28s.php</b> on line 
<b>69</b><br>
Like, dude!  Couldn't gzopen 
ftp://ftp.ncbi.nih.gov/genbank/gbpln3.seq.gz!
The gzopen returned

-----------------------------------------------------
("Warning - Success?????")

(the section of code that does this is:

-----------------------------------------------------
if(!($fhandle=gzopen($filename,"r")))
		{
		print("Like, dude!  Couldn't gzopen 
$filename!\n");
		print("The gzopen returned $fhandle\n");
		}
-----------------------------------------------------
where filename has obviously been passed as 
ftp://ftp.ncbi.nih.gov/genbank/gbpln3.seq.gz

There's a pause that implies the connection attempt is 
being made.  
(quick update, I just re-ran the script and did a capture 
with 'ethereal' - a connection IS being made and, passive 
mode is being switched to, and the RETR is started on the 
file, and about 3 1K packets seem to come across.  Are FTP 
URL's supposed to work?  Is this a 'gzopen ftp://' bug 
rather than an error message bug?)

I'll report the "Please Oh Please add http/ftp URL support 
to gzopen like fopen has!" separately as a feature request 
later, presuming it doesn't turn out that it's already 
been done and I just don't know what I'm doing...  Thanks!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-03 02:01 UTC] georg@php.net
For opening zip-files via ftp or httpd, there is a little 
note in the manual:

Note: The current CVS version 4.0.4-dev introduces a 
fopen-wrapper for .gz-files, so that you can use a special 
'zlib:' URL to access compressed files transparently using 
the normal f*() file access functions if you prepend the 
filename or path with a 'zlib:' prefix when calling 
fopen(). 

 This feature requires a C runtime library that provides 
the fopencookie() function. To my current knowledge the 
GNU libc is the only library that provides this feature. 

But for sure, this is not a solution for the errormessage 
:-)

 [2002-01-08 17:02 UTC] dubious at 2xtreme dot net
(Just got email back from Georg, replying to my response 
to this [emailed directly as the bug-editing was down at 
the time]).

It sounds like neither gzopen nor zlib:// work for remote 
files at all.

Is this a bug or should I submit it as a feature request?

P.S. Thanks again for the reply!

 [2002-01-17 13:08 UTC] georg@php.net
Currently its not possible, to combine diffrent wrappers.
So you can't use fopen("zlib:url/file.gz") or 
gzopen("url/file.gz").

I changed it to a documentation problem, maybe someone can 
add a note, that is not possible yet to combine wrappers.

 [2002-04-06 06:12 UTC] sander@php.net
Isn't this possible with the new streams (in 4.3.0)?
 [2002-04-06 07:33 UTC] wez@php.net
Yes, the new streams allow "nesting" a sequences of wrappers:
fopen("bzip2://zlib://http://host.domain", "r") should
in theory work, even it it doesn't make much sense.
Not every wrapper/stream is compatible in this way on
all systems, particularly if fopencookie is not part of
the systems c library.
 [2002-04-06 07:40 UTC] wez@php.net
As an additional note, zlib: wrapper no longer requires fopencookie, so I would expect zlib://http:// and zlib://ftp:// to work on all systems.
Likewise, gzopen("http://") and gzopen("ftp://") should
also work on all systems.
This needs testing (you are welcome to try the current
CVS/recent snapshot).
 [2002-04-06 10:18 UTC] sander@php.net
Closing.

Note: this will NOT work in 4.2.0, only in 4.3.0. If you want to try it, grab the latest CVS or a snapshot from http://snaps.php.net
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 10 23:01:29 2025 UTC