pollita         Mon Mar 20 22:38:55 2006 UTC

  Modified files:              
    /phpdoc/en/appendices       wrappers.xml 
  Log:
  Document user-agent's undocumented feature: Custom request headers
  
http://cvs.php.net/viewcvs.cgi/phpdoc/en/appendices/wrappers.xml?r1=1.58&r2=1.59&diff_format=u
Index: phpdoc/en/appendices/wrappers.xml
diff -u phpdoc/en/appendices/wrappers.xml:1.58 
phpdoc/en/appendices/wrappers.xml:1.59
--- phpdoc/en/appendices/wrappers.xml:1.58      Tue Dec  6 14:33:50 2005
+++ phpdoc/en/appendices/wrappers.xml   Mon Mar 20 22:38:55 2006
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.58 $ -->
+<!-- $Revision: 1.59 $ -->
 <appendix id="wrappers">
  <title>List of Supported Protocols/Wrappers</title>
  <para>
@@ -365,6 +365,40 @@
     for the <literal>ssl://</literal> transport.
    </simpara>
   </note>
+
+  <para>
+   Custom headers may be sent with an HTTP request prior to
+   version 5 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.
+   This method works in PHP4 and all later versions.
+  </para>
+  <para>
+   <example>
+    <title>Sending custom headers with an HTTP request</title>
+    <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>
+  </para>
  </section>
 
  <section id="wrappers.ftp">

Reply via email to