Incorporate user note re: following redirects.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@137859 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Sara Golemon 2003-08-15 15:16:32 +00:00
parent 7218bcc708
commit 42a2d70b78

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.23 $ -->
<!-- $Revision: 1.24 $ -->
<appendix id="wrappers">
<title>List of Supported Protocols/Wrappers</title>
<para>
@ -32,8 +32,35 @@
<simpara>
Redirects have been supported since PHP 4.0.5; if you are using
an earlier version you will need to include trailing slashes in
your URLs.
your URLs. If it's important to know the url of the resource where
your document came from (after all redirects have been processed),
you'll need to process the series of response headers returned by the
stream.
</simpara>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
$url = 'http://www.example.com/redirecting_page.php';
$fp = fopen($url, 'r');
/* Prior to PHP 4.3.0 use $http_response_header
instead of stream_get_meta_data() */
foreach(stream_get_meta_data($fp) as $response) {
/* Were we redirected? */
if (substr(strtolower($response), 0, 10) == 'location: ') {
/* update $url with where we were redirected to */
$url = substr($response, 10);
}
}
?>
]]>
</programlisting>
</informalexample>
<simpara>
The stream allows access to the <emphasis>body</emphasis> of
the resource; the headers are stored in the