mirror of
https://github.com/php/doc-en.git
synced 2026-03-23 23:32:18 +01:00
Abusing this ini parameter to send multiple headers is not something that should be included as an example in the manual. There are better ways to do it.
-- Provided by anonymous #32932 (ajf@ajf.me) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@331342 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
@@ -170,39 +170,6 @@ foreach ($meta_data['wrapper_data'] as $response) {
|
||||
]]>
|
||||
</programlisting>
|
||||
</example><!-- }}} -->
|
||||
|
||||
<example xml:id="wrappers.http.example.custom.headers"> <!-- {{{ -->
|
||||
<title>Sending custom headers with an HTTP request</title>
|
||||
<para>
|
||||
Custom headers may be sent using <link linkend="context.http">context
|
||||
options</link>. It is also possible to use this hack:
|
||||
Custom headers may be sent with an HTTP request
|
||||
by taking advantage of a side-effect in the
|
||||
handling of the <literal>user_agent</literal> INI setting.
|
||||
Set <literal>user_agent</literal> to any valid string
|
||||
(such as the default <literal>PHP/version</literal> setting)
|
||||
followed by a carriage-return/line-feed pair and any
|
||||
additional headers.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
ini_set('user_agent', "PHP\r\nX-MyCustomHeader: Foo");
|
||||
|
||||
$fp = fopen('http://www.example.com/index.php', 'r');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>Results in the following request being sent:</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
GET /index.php HTTP/1.0
|
||||
Host: www.example.com
|
||||
User-Agent: PHP
|
||||
X-MyCustomHeader: Foo
|
||||
]]>
|
||||
</screen>
|
||||
</example><!-- }}} -->
|
||||
</refsect1><!-- }}} -->
|
||||
|
||||
<refsect1 role="notes"><!-- {{{ -->
|
||||
|
||||
Reference in New Issue
Block a user