[ create a new paste ] login | about

Link: http://codepad.org/DoeR65RJ    [ raw code | fork ]

Plain Text, pasted on Jan 17:
Index: en/language/context/http.xml
===================================================================
--- en/language/context/http.xml	(revision 293676)
+++ en/language/context/http.xml	(working copy)
@@ -273,6 +273,36 @@
     </programlisting>
    </example><!-- }}} -->
   </para>
+    <para>
+   <example xml:id="context.http.example-fetch-ignore-redirect"><!-- {{{ -->
+    <title>Ignore redirects but fetch headers and content </title>
+    <programlisting role="php">
+<![CDATA[
+<?php
+
+$url = "http://www.example.org/header.php";
+
+$opts = array(
+	'http' => array('method' => 'GET',
+					'max_redirects' => '0',
+					'ignore_errors' => '1')
+	);
+
+$context = stream_context_create($opts);
+$stream = fopen($url, 'r', false, $context);
+
+// header information as well as meta data
+// about the stream
+var_dump(stream_get_meta_data($stream));
+
+// actual data at $url
+var_dump(stream_get_contents($stream));
+fclose($stream);
+?>
+]]>
+    </programlisting>
+   </example><!-- }}} -->
+  </para>
  </refsect1><!-- }}} -->
 
  <refsect1 role="notes">



Create a new paste based on this one


Comments: