cvs: peardoc /en/package http.xml /en/package/http http-request.xml /en/package/http/http-request TODO basic-auth.xml cookie.xml file-upload.xml
headers.xml intro.xml proxy-auth.xml

From: Date: Sat, 21 Feb 2004 16:46:09 +0000
Subject: cvs: peardoc /en/package http.xml /en/package/http http-request.xml /en/package/http/http-request TODO basic-auth.xml cookie.xml file-upload.xml
headers.xml intro.xml proxy-auth.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-2636@lists.php.net to get a copy of this message
mj Sat Feb 21 11:46:09 2004 EDT Added files: /peardoc/en/package/http http-request.xml /peardoc/en/package/http/http-request basic-auth.xml headers.xml proxy-auth.xml cookie.xml file-upload.xml intro.xml TODO Modified files: /peardoc/en/package http.xml Log: * Adding initial documentation for HTTP_Request

http://cvs.php.net/diff.php/peardoc/en/package/http.xml?r1=1.5&r2=1.6&ty=u Index: peardoc/en/package/http.xml diff -u peardoc/en/package/http.xml:1.5 peardoc/en/package/http.xml:1.6 --- peardoc/en/package/http.xml:1.5 Wed Jan 21 16:13:49 2004 +++ peardoc/en/package/http.xml Sat Feb 21 11:46:08 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <chapter id="package.http"> <title>HTTP</title> @@ -12,6 +12,7 @@ &package.http.http-client; &package.http.http-compress; &package.http.http-download; + &package.http.http-request; </chapter> <!-- Keep this comment at the end of the file http://cvs.php.net/co.php/peardoc/en/package/http/http-request.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-request.xml +++ peardoc/en/package/http/http-request.xml <!-- $Revision: 1.1 $ --> <sect1 id="package.http.http-request"> <title>HTTP_Request</title> <para> The package provides an easy way to perform HTTP requests. It supports GET/POST/HEAD/TRACE/PUT/DELETE, Basic authentication, Proxy, Proxy Authentication, SSL, file uploads etc. </para> &package.http.http-request.intro; &package.http.http-request.basic-auth; &package.http.http-request.cookie; &package.http.http-request.file-upload; &package.http.http-request.headers; &package.http.http-request.proxy-auth; </sect1> <!-- 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 sgml-parent-document:nil sgml-default-dtd-file:"../../../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 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-request/basic-auth.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-request/basic-auth.xml +++ peardoc/en/package/http/http-request/basic-auth.xml <!-- $Revision: 1.1 $ --> <refentry id="package.http.http-request.basic-auth"> <refnamediv> <refname>Basic Authentication</refname> <refpurpose> Authentication for protected websites </refpurpose> </refnamediv> <refsect1 id="package.http.http-request.basic-auth.intro"> <title>Introduction to Basic Authentication</title> <titleabbrev>Introduction</titleabbrev> <para> Basic Authentication is a challenge-response mechanism described in <ulink url="&url.rfc;2617">RFC 2617</ulink>. </para> </refsect1> <refsect1 id="package.http.http-request.basic-auth.usage"> <title>How to use Basic Authentication</title> <example> <title>Basic Authentication</title> <para> The following example assumes that one wants to fetch a page <filename>/protected.html</filename> on the host <literal>example.com</literal> that is protected using Basic Authentication. The necessary username to pass the authentication is <literal>johndoe</literal> and the appendant password is <literal>foo</literal>. </para> <programlisting role="php"> require_once "HTTP/Request.php"; $req =&amp; new HTTP_Request("http://example.com/protected.html"); $req->setBasicAuth("johndoe", "foo"); $response = $req->sendRequest(); if (PEAR::isError($response)) { echo $response->getMessage(); } else { echo $req->getResponseBody(); } </programlisting> </example> </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 sgml-parent-document:nil sgml-default-dtd-file:"../../../../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 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-request/headers.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-request/headers.xml +++ peardoc/en/package/http/http-request/headers.xml <!-- $Revision: 1.1 $ --> <refentry id="package.http.http-request.headers"> <refnamediv> <refname>Request headers</refname> <refpurpose> Adding additional headers to the HTTP request. </refpurpose> </refnamediv> <refsect1 id="package.http.http-request.headers.usage"> <title>How to add request headeres</title> <example> <title>Adding a custom request header</title> <para> In this example a HTTP header <literal>X-PHP-Version</literal> is added to the HTTP request. The value of this header is the version string of the PHP interpreter that is running the instance of <classname>HTTP_Request</classname>. </para> <programlisting role="php"> require_once "HTTP/Request.php"; $req =&amp; new HTTP_Request("http://example.com/"); $req->addHeader("X-PHP-Version", phpversion()); $response = $req->sendRequest(); if (PEAR::isError($response)) { echo $response->getMessage(); } else { echo $req->getResponseBody(); } </programlisting> </example> <para> Headers that have been added to the <classname>HTTP_Request</classname> object can be removed with the method <function>removeHeader</function>, before <function>sendRequest</function> has been called. </para> </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 sgml-parent-document:nil sgml-default-dtd-file:"../../../../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 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-request/proxy-auth.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-request/proxy-auth.xml +++ peardoc/en/package/http/http-request/proxy-auth.xml <!-- $Revision: 1.1 $ --> <refentry id="package.http.http-request.proxy-auth"> <refnamediv> <refname>Proxy Authorization</refname> <refpurpose> Making use of a HTTP proxy </refpurpose> </refnamediv> <refsect1 id="package.http.http-request.proxy-auth.usage"> <title>How to use Proxy Authorization</title> <example> <title>Using a proxy server with anonymous access</title> <para> In this example it is assumed that one wants to use the machine with the hostname <literal>proxy.example.com</literal>, where a proxy server is listening on port <literal>8080</literal>, to proxy the outgoing connection to example.com. </para> <para> The second parameter of <function>setProxy</function> is optional and defaults to <literal>8080</literal>. </para> <programlisting role="php"> require_once "HTTP/Request.php"; $req =&amp; new HTTP_Request("http://example.com/"); $req->setProxy("proxy.example.com", 8080); </programlisting> </example> <example> <title>Using proxy authorization</title> <para> This is the same example as above, except that a username/password tuple is provided, which authorizes the user at the proxy server: The username is <literal>johndoe</literal> and the appendant password is <literal>foo</literal>. </para> <programlisting role="php"> require_once "HTTP/Request.php"; $req =&amp; new HTTP_Request("http://example.com/"); $req->setProxy("proxy.example.com", 8080, "johndoe", "foo"); </programlisting> </example> </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 sgml-parent-document:nil sgml-default-dtd-file:"../../../../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 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-request/cookie.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-request/cookie.xml +++ peardoc/en/package/http/http-request/cookie.xml <!-- $Revision: 1.1 $ --> <refentry id="package.http.http-request.cookie"> <refnamediv> <refname>Cookies</refname> <refpurpose> Making use of Cookies within <classname>HTTP_Request</classname>. </refpurpose> </refnamediv> <refsect1 id="package.http.http-request.cookie.usage.add"> <title>How to add Cookie to a HTTP request</title> <example> <title>Adding a cookie to the request</title> <para> In this example a cookie named <literal>version</literal> is added to the HTTP request. The value of this cookie is the version string of the PHP interpreter that is running the instance of <classname>HTTP_Request</classname>. </para> <programlisting role="php"> require_once "HTTP/Request.php"; $req =&amp; new HTTP_Request("http://example.com/"); $req->addCookie("version", phpversion()); $response = $req->sendRequest(); if (PEAR::isError($response)) { echo $response->getMessage(); } else { echo $req->getResponseBody(); } </programlisting> </example> <example> <title>Reading cookies from a HTTP response</title> <para> Reading cookies that come with a HTTP response is shown in this following example. </para> <programlisting role="php"> require_once "HTTP/Request.php"; $req =&amp; new HTTP_Request("http://example.com/"); $response = $req->sendRequest(); if (PEAR::isError($response)) { echo $response->getMessage(); } else { print_r($response->getResponseCookies()); } </programlisting> </example> </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 sgml-parent-document:nil sgml-default-dtd-file:"../../../../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 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-request/file-upload.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-request/file-upload.xml +++ peardoc/en/package/http/http-request/file-upload.xml <!-- $Revision: 1.1 $ --> <refentry id="package.http.http-request.file-upload"> <refnamediv> <refname>File uploads</refname> <refpurpose> Uploading files via HTTP </refpurpose> </refnamediv> <refsect1 id="package.http.http-request.file-upload.usage"> <title>How to use file uploads</title> <example> <title>Upload a PDF document</title> <para> In this example a file named <filename>/home/johndoe/text.pdf</filename> is uploaded to the remote machine <literal>upload.example.com</literal> under the name <literal>johndoe-text.pdf</literal>. Additionally Basic Authentication is used to ensure that John is allowed to upload something. </para> <programlisting role="php"> require_once "HTTP/Request.php"; $req =&amp; new HTTP_Request("http://upload.example.com/upload.php"); $req->setBasicAuth("johndoe", "foo"); $result = $req->addFile("johndoe-txt.pdf", "/home/johndoe/text.pdf"); if (PEAR::isError($result)) { echo $result->getMessage(); } else { $response = $req->sendRequest(); if (PEAR::isError($response)) { echo $response->getMessage(); } else { echo $req->getResponseBody(); } } </programlisting> </example> </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 sgml-parent-document:nil sgml-default-dtd-file:"../../../../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 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-request/intro.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-request/intro.xml +++ peardoc/en/package/http/http-request/intro.xml <!-- $Revision: 1.1 $ --> <refentry id="package.http.http-request.intro"> <refnamediv> <refname>Introduction</refname> <refpurpose> Introduction to <classname>HTTP_Request</classname> </refpurpose> </refnamediv> <refsect1 id="package.http.http-request.intro.overview"> <title>Overview</title> <para> With this package, one can easily perform HTTP request from within <acronym>PHP</acronym> scripts. It support GET/POST/HEAD/TRACE/PUT/DELETE, Basic authentication, Proxy, Proxy Authentication, SSL, file uploads etc. </para> </refsect1> <refsect1 id="package.http.http-request.intro.examples"> <title>A few examples</title> <example> <title> Fetches <ulink url="http://yahoo.com/">yahoo.com</ulink> and displays it </title> <programlisting role="php"> require_once "HTTP/Request.php"; $req =&amp; new HTTP_Request("http://www.yahoo.com/"); if (!PEAR::isError($req->sendRequest())) { echo $req->getResponseBody(); } </programlisting> </example> <example> <title>Fetching two website in a row</title> <para> In this example, two websites are fetched and displayed. To the first one a POST parameter is passed. The POST data stack is cleared before the second website is fetched. </para> <programlisting role="php"> require_once "HTTP/Request.php"; $req =&amp; new HTTP_Request("http://www.php.net"); $req->setMethod(HTTP_REQUEST_METHOD_POST); $req->addPostData("Foo", "bar"); if (!PEAR::isError($req->sendRequest())) { $response1 = $req->getResponseBody(); } else { $response1 = ""; } $req->setMethod(HTTP_REQUEST_METHOD_GET); $req->setURL("http://pear.php.net"); $req->clearPostData(); if (!PEAR::isError($req->sendRequest())) { $response2 = $req->getResponseBody(); } else { $response2 = ""; } echo $response1; echo $response2; </programlisting> </example> </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 sgml-parent-document:nil sgml-default-dtd-file:"../../../../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 -->
« previous php.pear.doc (#2636) next »