Simple HTTP request, with "Range" header
| From: | Ken | Date: | Wed, 13 Aug 2003 02:30:21 +0000 |
| Subject: | Simple HTTP request, with "Range" header | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-159384@lists.php.net to get a copy of this message | ||
What I want to do is write something simple in PHP that makes an HTTP request, takes the data
received, and passes it through.
Specifically, I am hoping to retrieve just a part of a file from the web server. If I wanted the
whole file I would just do header("Location:...");
I imagine I would want to form a basic get header request, with URL, whatever else I need, and a
"Range:bytes=1000-2000" header. If I understand correctly, the (HTTP/1.1) web server
would return the document I want, just bytes 1000-2000.
Then I would take whatever is received and use a pass through function to pipe it out.
I realize it might be simpler to do a file read (assuming I'm doing this on the very same
server as the document), and then just seek to the given position and pass through whatever I wish.
As far as that option goes, I was concerned that this might somehow be less efficient than the above
scenario, which would be letting the web server do the seeking. But maybe both options are
inefficient. Or maybe they're both reasonable!
The real goal is to be able to take a URL like this:
http://example.com/myscript.php?url=example2.org/test.bin&start=1000
and return the document from http://example2.org/test.bin
to the user's browser, starting at byte 1000.
Any pointers at all would be appreciated.
- Ken