1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="wrappers.http" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="verify_info:false" role="stream_wrapper">
<refnamediv>
<refname>http://</refname>
<refname>https://</refname>
<refpurpose>Accessing HTTP(s) URLs</refpurpose>
</refnamediv>
<refsect1 role="description"><!-- {{{ -->
&reftitle.description;
<para>
Allows read-only access to files/resources via HTTP.
By default, a HTTP 1.0 GET is used. A <literal>Host:</literal> header is sent with the request
to handle name-based virtual hosts. If you have configured
a <link linkend="ini.user-agent">user_agent</link> string using
your &php.ini; file or the stream context, it will also be included
in the request.
</para>
<simpara>
The stream allows access to the <emphasis>body</emphasis> of
the resource; the headers are stored in the
<varname>$http_response_header</varname> variable.
</simpara>
<simpara>
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>
<simpara>
The <link linkend="ini.from">from</link> directive will be used for the
<literal>From:</literal> header if set and not overwritten by the
<xref linkend="context" />.
</simpara>
</refsect1><!-- }}} -->
<refsect1 role="usage"> <!-- {{{ -->
&reftitle.usage;
<itemizedlist>
<listitem><simpara><filename>http://example.com</filename></simpara></listitem>
<listitem><simpara><filename>http://example.com/file.php?var1=val1&var2=val2</filename></simpara></listitem>
<listitem><simpara><filename>http://user:password@example.com</filename></simpara></listitem>
<listitem><simpara><filename>https://example.com</filename></simpara></listitem>
<listitem><simpara><filename>https://example.com/file.php?var1=val1&var2=val2</filename></simpara></listitem>
<listitem><simpara><filename>https://user:password@example.com</filename></simpara></listitem>
</itemizedlist>
</refsect1> <!-- }}} -->
<refsect1 role="options"><!-- {{{ -->
&reftitle.options;
<para>
<table>
<title>Wrapper Summary</title>
<tgroup cols="2">
<thead>
<row>
<entry>Attribute</entry>
<entry>Supported</entry>
</row>
</thead>
<tbody>
<row>
<entry>Restricted by <link linkend="ini.allow-url-fopen">allow_url_fopen</link></entry>
<entry>Yes</entry>
</row>
<row>
<entry>Allows Reading</entry>
<entry>Yes</entry>
</row>
<row>
<entry>Allows Writing</entry>
<entry>No</entry>
</row>
<row>
<entry>Allows Appending</entry>
<entry>No</entry>
</row>
<row>
<entry>Allows Simultaneous Reading and Writing</entry>
<entry>N/A</entry>
</row>
<row>
<entry>Supports <function>stat</function></entry>
<entry>No</entry>
</row>
<row>
<entry>Supports <function>unlink</function></entry>
<entry>No</entry>
</row>
<row>
<entry>Supports <function>rename</function></entry>
<entry>No</entry>
</row>
<row>
<entry>Supports <function>mkdir</function></entry>
<entry>No</entry>
</row>
<row>
<entry>Supports <function>rmdir</function></entry>
<entry>No</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</refsect1> <!-- }}} -->
<refsect1 role="examples"><!-- {{{ -->
&reftitle.examples;
<example xml:id="wrappers.http.example.basic"><!-- {{{ -->
<title>Detecting which URL we ended up on after redirects</title>
<programlisting role="php">
<![CDATA[
<?php
$url = 'http://www.example.com/redirecting_page.php';
$fp = fopen($url, 'r');
$meta_data = stream_get_meta_data($fp);
foreach ($meta_data['wrapper_data'] as $response) {
/* Were we redirected? */
if (strtolower(substr($response, 0, 10)) == 'location: ') {
/* update $url with where we were redirected to */
$url = substr($response, 10);
}
}
?>
]]>
</programlisting>
</example><!-- }}} -->
</refsect1><!-- }}} -->
<refsect1 role="notes"><!-- {{{ -->
&reftitle.notes;
<note>
<simpara>
HTTPS is only supported when the <link linkend="book.openssl">openssl</link>
extension is enabled.
</simpara>
</note>
<simpara>
HTTP connections are read-only; writing data or copying
files to an HTTP resource is not supported.
</simpara>
<simpara>
Sending <emphasis>POST</emphasis> and <emphasis>PUT</emphasis> requests, for example,
can be done with the help of <link linkend="context.http">HTTP Contexts</link>.
</simpara>
</refsect1><!-- }}} -->
<refsect1 role="seealso"><!-- {{{ -->
&reftitle.seealso;
<simplelist>
<member><xref linkend="context.http" /></member>
<member><varname>$http_response_header</varname></member>
<member><function>stream_get_meta_data</function></member>
</simplelist>
</refsect1><!-- }}} -->
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
|