* docs
[m6w6/ext-http] / docs / functions.html
1 Content-type: text/html
2 X-Powered-By: PHP/5.0.1
3
4 <html>
5 <head>
6 <title>Function Summary of ext/http</title>
7 <style>
8 body {
9 font-size: 80%;
10 font-family: sans-serif;
11 }
12 h2 {
13 color: #339;
14 clear: both;
15 font-size: 1.2em;
16 background: #ffc;
17 padding: .2em;
18 }
19 p {
20 margin-left: 1em;
21 }
22 pre {
23 font-size: 1.2em;
24 }
25 br {
26 display: none;
27 }
28 blockquote {
29 margin-bottom: 3em;
30 border: 1px solid #ccc;
31 background: #f0f0f0;
32 padding: 0em 1em;
33 width: auto;
34 float: left;
35 }
36 p, pre {
37 clear: both;
38 }
39 p br, pre code br {
40 display: block;
41 }
42 </style>
43 </head>
44 <body><h1>http_functions.c</h1>
45 <h2 id="http_date">string http_date([int timestamp])</h2>
46 <p>This function returns a valid HTTP date regarding RFC 822/1123<br />
47 looking like: "Wed, 22 Dec 2004 11:34:47 GMT"</p>
48 <h2 id="http_absolute_uri">string http_absolute_uri(string url[, string proto[, string host[, int port]]])</h2>
49 <p>This function returns an absolute URI constructed from url.<br />
50 If the url is already abolute but a different proto was supplied,<br />
51 only the proto part of the URI will be updated. If url has no<br />
52 path specified, the path of the current REQUEST_URI will be taken.<br />
53 The host will be taken either from the Host HTTP header of the client<br />
54 the SERVER_NAME or just localhost if prior are not available.<br />
55 <br />
56 Some examples:</p><pre> url = "page.php" => http://www.example.com/current/path/page.php<br />
57 url = "/page.php" => http://www.example.com/page.php<br />
58 url = "/page.php", proto = "https" => https://www.example.com/page.php<br />
59 </pre></p>
60 <h2 id="http_negotiate_language">string http_negotiate_language(array supported[, string default = 'en-US'])</h2>
61 <p>This function negotiates the clients preferred language based on its<br />
62 Accept-Language HTTP header. It returns the negotiated language or<br />
63 the default language if none match.<br />
64 <br />
65 The qualifier is recognized and languages without qualifier are rated highest.<br />
66 <br />
67 The supported parameter is expected to be an array having<br />
68 the supported languages as array values.<br />
69 <br />
70 Example:</p><pre><blockquote><code><span style="color: #000000"><br />
71 <span style="color: #0000BB">&lt;?php<br />$langs </span><span style="color: #007700">= array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'en-US'</span><span style="color: #007700">,</span><span style="color: #FF8000">// default<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'fr'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'fr-FR'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'de'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'de-DE'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'de-AT'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'de-CH'</span><span style="color: #007700">,<br />);<br />include </span><span style="color: #DD0000">'./langs/'</span><span style="color: #007700">. </span><span style="color: #0000BB">http_negotiate_language</span><span style="color: #007700">(</span><span style="color: #0000BB">$langs</span><span style="color: #007700">) .</span><span style="color: #DD0000">'.php'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span><br />
72 </span><br />
73 </code></blockquote><br />
74 <br />
75 </pre></p>
76 <h2 id="http_negotiate_charset">string http_negotiate_charset(array supported[, string default = 'iso-8859-1'])</h2>
77 <p>This function negotiates the clients preferred charset based on its<br />
78 Accept-Charset HTTP header. It returns the negotiated charset or<br />
79 the default charset if none match.<br />
80 <br />
81 The qualifier is recognized and charset without qualifier are rated highest.<br />
82 <br />
83 The supported parameter is expected to be an array having<br />
84 the supported charsets as array values.<br />
85 <br />
86 Example:</p><pre><blockquote><code><span style="color: #000000"><br />
87 <span style="color: #0000BB">&lt;?php<br />$charsets </span><span style="color: #007700">= array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'iso-8859-1'</span><span style="color: #007700">, </span><span style="color: #FF8000">// default<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'iso-8859-2'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'iso-8859-15'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'utf-8'<br /></span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$pref </span><span style="color: #007700">= </span><span style="color: #0000BB">http_negotiate_charset</span><span style="color: #007700">(</span><span style="color: #0000BB">$charsets</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">strcmp</span><span style="color: #007700">(</span><span style="color: #0000BB">$pref</span><span style="color: #007700">, </span><span style="color: #DD0000">'iso-8859-1'</span><span style="color: #007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">iconv_set_encoding</span><span style="color: #007700">(</span><span style="color: #DD0000">'internal_encoding'</span><span style="color: #007700">, </span><span style="color: #DD0000">'iso-8859-1'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">iconv_set_encoding</span><span style="color: #007700">(</span><span style="color: #DD0000">'output_encoding'</span><span style="color: #007700">, </span><span style="color: #0000BB">$pref</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ob_start</span><span style="color: #007700">(</span><span style="color: #DD0000">'ob_iconv_handler'</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span><br />
88 </span><br />
89 </code></blockquote><br />
90 <br />
91 </pre></p>
92 <h2 id="http_send_status">bool http_send_status(int status)</h2>
93 <p>Send HTTP status code.</p>
94 <h2 id="http_send_last_modified">bool http_send_last_modified([int timestamp])</h2>
95 <p>This converts the given timestamp to a valid HTTP date and<br />
96 sends it as "Last-Modified" HTTP header. If timestamp is<br />
97 omitted, current time is sent.</p>
98 <h2 id="http_send_content_type">bool http_send_content_type([string content_type = 'application/x-octetstream'])</h2>
99 <p>Sets the content type.</p>
100 <h2 id="http_send_content_disposition">bool http_send_content_disposition(string filename[, bool inline = false])</h2>
101 <p>Set the Content Disposition. The Content-Disposition header is very useful<br />
102 if the data actually sent came from a file or something similar, that should<br />
103 be "saved" by the client/user (i.e. by browsers "Save as..." popup window).</p>
104 <h2 id="http_match_modified">bool http_match_modified([int timestamp[, for_range = false]])</h2>
105 <p>Matches the given timestamp against the clients "If-Modified-Since" resp.<br />
106 "If-Unmodified-Since" HTTP headers.</p>
107 <h2 id="http_match_etag">bool http_match_etag(string etag[, for_range = false])</h2>
108 <p>This matches the given ETag against the clients<br />
109 "If-Match" resp. "If-None-Match" HTTP headers.</p>
110 <h2 id="http_cache_last_modified">bool http_cache_last_modified([int timestamp_or_expires]])</h2>
111 <p>If timestamp_or_exires is greater than 0, it is handled as timestamp<br />
112 and will be sent as date of last modification. If it is 0 or omitted,<br />
113 the current time will be sent as Last-Modified date. If it's negative,<br />
114 it is handled as expiration time in seconds, which means that if the<br />
115 requested last modification date is not between the calculated timespan,<br />
116 the Last-Modified header is updated and the actual body will be sent.</p>
117 <h2 id="http_cache_etag">bool http_cache_etag([string etag])</h2>
118 <p>This function attempts to cache the HTTP body based on an ETag,<br />
119 either supplied or generated through calculation of the MD5<br />
120 checksum of the output (uses output buffering).<br />
121 <br />
122 If clients "If-None-Match" header matches the supplied/calculated<br />
123 ETag, the body is considered cached on the clients side and<br />
124 a "304 Not Modified" status code is issued.</p>
125 <h2 id="ob_httpetaghandler">string ob_httpetaghandler(string data, int mode)</h2>
126 <p>For use with ob_start().<br />
127 Note that this has to be started as first output buffer.<br />
128 WARNING: Don't use with http_send_*().</p>
129 <h2 id="http_redirect">void http_redirect([string url[, array params[, bool session,[ bool permanent]]]])</h2>
130 <p>Redirect to a given url.<br />
131 The supplied url will be expanded with http_absolute_uri(), the params array will<br />
132 be treated with http_build_query() and the session identification will be appended<br />
133 if session is true.<br />
134 <br />
135 Depending on permanent the redirection will be issued with a permanent<br />
136 ("301 Moved Permanently") or a temporary ("302 Found") redirection<br />
137 status code.<br />
138 <br />
139 To be RFC compliant, "Redirecting to <a>URI</a>." will be displayed,<br />
140 if the client doesn't redirect immediatly.</p>
141 <h2 id="http_send_data">bool http_send_data(string data)</h2>
142 <p>Sends raw data with support for (multiple) range requests.</p>
143 <h2 id="http_send_file">bool http_send_file(string file)</h2>
144 <p>Sends a file with support for (multiple) range requests.</p>
145 <h2 id="http_send_stream">bool http_send_stream(resource stream)</h2>
146 <p>Sends an already opened stream with support for (multiple) range requests.</p>
147 <h2 id="http_chunked_decode">string http_chunked_decode(string encoded)</h2>
148 <p>This function decodes a string that was HTTP-chunked encoded.<br />
149 Returns false on failure.</p>
150 <h2 id="http_split_response">array http_split_response(string http_response)</h2>
151 <p>This function splits an HTTP response into an array with headers and the<br />
152 content body. The returned array may look simliar to the following example:</p><pre><blockquote><code><span style="color: #000000"><br />
153 <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">0 </span><span style="color: #007700">=&gt; array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'Status' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'200 Ok'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'Content-Type' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'Content-Language' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'en-US'<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">1 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"Hello World!"<br /></span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span><br />
154 </span><br />
155 </code></blockquote><br />
156 <br />
157 </pre></p>
158 <h2 id="http_parse_headers">array http_parse_headers(string header)</h2>
159 <p></p>
160 <h2 id="http_get_request_headers">array http_get_request_headers(void)</h2>
161 <p></p>
162 <h2 id="http_get">string http_get(string url[, array options[, array &info]])</h2>
163 <p>Performs an HTTP GET request on the supplied url.<br />
164 <br />
165 The second parameter is expected to be an associative<br />
166 array where the following keys will be recognized:</p><pre> - redirect: int, whether and how many redirects to follow<br />
167 - unrestrictedauth: bool, whether to continue sending credentials on<br />
168 redirects to a different host<br />
169 - proxyhost: string, proxy host in "host[:port]" format<br />
170 - proxyport: int, use another proxy port as specified in proxyhost<br />
171 - proxyauth: string, proxy credentials in "user:pass" format<br />
172 - proxyauthtype: int, HTTP_AUTH_BASIC and/or HTTP_AUTH_NTLM<br />
173 - httpauth: string, http credentials in "user:pass" format<br />
174 - httpauthtype: int, HTTP_AUTH_BASIC, DIGEST and/or NTLM<br />
175 - compress: bool, whether to allow gzip/deflate content encoding<br />
176 (defaults to true)<br />
177 - port: int, use another port as specified in the url<br />
178 - referer: string, the referer to sends<br />
179 - useragent: string, the user agent to send<br />
180 (defaults to PECL::HTTP/version (PHP/version)))<br />
181 - headers: array, list of custom headers as associative array<br />
182 like array("header" => "value")<br />
183 - cookies: array, list of cookies as associative array<br />
184 like array("cookie" => "value")<br />
185 - cookiestore: string, path to a file where cookies are/will be stored<br />
186 - resume: int, byte offset to start the download from;<br />
187 if the server supports ranges<br />
188 - maxfilesize: int, maximum file size that should be downloaded;<br />
189 has no effect, if the size of the requested entity is not known<br />
190 - lastmodified: int, timestamp for If-(Un)Modified-Since header<br />
191 - timeout: int, seconds the request may take<br />
192 - connecttimeout: int, seconds the connect may take</pre><p>The optional third parameter will be filled with some additional information<br />
193 in form af an associative array, if supplied, like the following example:</p><pre><blockquote><code><span style="color: #000000"><br />
194 <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">array (<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'effective_url' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'http://localhost'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'response_code' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">403</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'total_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0.017</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'namelookup_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0.013</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'connect_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0.014</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'pretransfer_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0.014</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'size_upload' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'size_download' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">202</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'speed_download' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">11882</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'speed_upload' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'header_size' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">145</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'request_size' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">62</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'ssl_verifyresult' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'filetime' </span><span style="color: #007700">=&gt; -</span><span style="color: #0000BB">1</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'content_length_download' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">202</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'content_length_upload' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'starttransfer_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0.017</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'content_type' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'text/html; charset=iso-8859-1'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'redirect_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'redirect_count' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'private' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">''</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'http_connectcode' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'httpauth_avail' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'proxyauth_avail' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />)<br /></span><span style="color: #0000BB">?&gt;</span><br />
195 </span><br />
196 </code></blockquote><br />
197 <br />
198 </pre></p>
199 <h2 id="http_head">string http_head(string url[, array options[, array &info]])</h2>
200 <p>Performs an HTTP HEAD request on the suppied url.<br />
201 Returns the HTTP response as string.<br />
202 See http_get() for a full list of available options.</p>
203 <h2 id="http_post_data">string http_post_data(string url, string data[, array options[, &info]])</h2>
204 <p>Performs an HTTP POST request, posting data.<br />
205 Returns the HTTP response as string.<br />
206 See http_get() for a full list of available options.</p>
207 <h2 id="http_post_array">string http_post_array(string url, array data[, array options[, array &info]])</h2>
208 <p>Performs an HTTP POST request, posting www-form-urlencoded array data.<br />
209 Returns the HTTP response as string.<br />
210 See http_get() for a full list of available options.</p>
211 <h2 id="http_auth_basic">bool http_auth_basic(string user, string pass[, string realm = "Restricted"])</h2>
212 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
213 <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">http_auth_basic</span><span style="color: #007700">(</span><span style="color: #DD0000">'mike'</span><span style="color: #007700">, </span><span style="color: #DD0000">'s3c|r3t'</span><span style="color: #007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">'&lt;h1&gt;Authorization failed!&lt;/h1&gt;'</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span><br />
214 </span><br />
215 </code></blockquote><br />
216 <br />
217 </pre></p>
218 <h2 id="http_auth_basic_cb">bool http_auth_basic_cb(mixed callback[, string realm = "Restricted"])</h2>
219 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
220 <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">auth_cb</span><span style="color: #007700">(</span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$pass</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;global </span><span style="color: #0000BB">$db</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$query </span><span style="color: #007700">= </span><span style="color: #DD0000">'SELECT pass FROM users WHERE user='</span><span style="color: #007700">. </span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">quoteSmart</span><span style="color: #007700">(</span><span style="color: #0000BB">$user</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if (</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$realpass </span><span style="color: #007700">= </span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getOne</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return </span><span style="color: #0000BB">$pass </span><span style="color: #007700">=== </span><span style="color: #0000BB">$realpass</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;return </span><span style="color: #0000BB">false</span><span style="color: #007700">;<br />}<br />if (!</span><span style="color: #0000BB">http_auth_basic_cb</span><span style="color: #007700">(</span><span style="color: #DD0000">'auth_cb'</span><span style="color: #007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">'&lt;h1&gt;Authorization failed&lt;/h1&gt;'</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span><br />
221 </span><br />
222 </code></blockquote><br />
223 <br />
224 </pre></p>
225 <h2 id="http_build_query">string http_build_query(mixed formdata [, string prefix])</h2>
226 <p>Generates a form-encoded query string from an associative array or object.</p>
227 <hr noshade>
228 <h1>http_methods.c</h1>
229 <h2 id="HTTPi_Response___construct">void HTTPi_Response::__construct(bool cache, bool gzip)</h2>
230 <p>Instantiates a new HTTPi_Response object, which can be used to send<br />
231 any data/resource/file to an HTTP client with caching and multiple<br />
232 ranges/resuming support.<br />
233 <br />
234 NOTE: GZIPping is not implemented yet.</p>
235 <h2 id="HTTPi_Response_setCache">bool HTTPi_Response::setCache(bool cache)</h2>
236 <p>Whether it sould be attempted to cache the entitity.<br />
237 This will result in necessary caching headers and checks of clients<br />
238 "If-Modified-Since" and "If-None-Match" headers. If one of those headers<br />
239 matches a "304 Not Modified" status code will be issued.<br />
240 <br />
241 NOTE: If you're using sessions, be shure that you set session.cache_limiter<br />
242 to something more appropriate than "no-cache"!</p>
243 <h2 id="HTTPi_Response_getCache">bool HTTPi_Response::getCache()</h2>
244 <p>Get current caching setting.</p>
245 <h2 id="HTTPi_Response_setGzip">bool HTTPi_Response::setGzip(bool gzip)</h2>
246 <p>Enable on-thy-fly gzipping of the sent entity. NOT IMPLEMENTED YET.</p>
247 <h2 id="HTTPi_Response_getGzip">bool HTTPi_Response::getGzip()</h2>
248 <p>Get current gzipping setting.</p>
249 <h2 id="HTTPi_Response_setCacheControl">bool HTTPi_Response::setCacheControl(string control[, bool raw = false])</h2>
250 <p>Set a custom cache-control header, usually being "private" or "public"; if<br />
251 $raw is set to true the header will be sent as-is.</p>
252 <h2 id="HTTPi_Response_getCacheControl">string HTTPi_Response::getCacheControl()</h2>
253 <p>Get current Cache-Control header setting.</p>
254 <h2 id="HTTPi_Response_setContentType">bool HTTPi_Response::setContentType(string content_type)</h2>
255 <p>Set the content-type of the sent entity.</p>
256 <h2 id="HTTPi_Response_getContentType">string HTTPi_Response::getContentType()</h2>
257 <p>Get current Content-Type header setting.</p>
258 <h2 id="HTTPi_Response_setContentDisposition">bool HTTPi_Response::setContentDisposition(string filename[, bool inline = false])</h2>
259 <p>Set the Content-Disposition of the sent entity. This setting aims to suggest<br />
260 the receiveing user agent how to handle the sent entity; usually the client<br />
261 will show the user a "Save As..." popup.</p>
262 <h2 id="HTTPi_Response_getContentDisposition">array HTTPi_Response::getContentDisposition()</h2>
263 <p>Get current Content-Disposition setting.<br />
264 Will return an associative array like:</p><pre>array(<br />
265 'filename' => 'foo.bar',<br />
266 'inline' => false<br />
267 )<br />
268 </pre></p>
269 <h2 id="HTTPi_Response_setETag">bool HTTPi_Response::setETag(string etag)</h2>
270 <p>Set a custom ETag. Use this only if you know what you're doing.</p>
271 <h2 id="HTTPi_Response_getETag">string HTTPi_Response::getETag()</h2>
272 <p>Get the previously set custom ETag.</p>
273 <h2 id="HTTPi_Response_setData">bool HTTPi_Response::setData(string data)</h2>
274 <p>Set the data to be sent.</p>
275 <h2 id="HTTPi_Response_getData">string HTTPi_Response::getData()</h2>
276 <p>Get the previously set data to be sent.</p>
277 <h2 id="HTTPi_Response_setStream">bool HTTPi_Response::setStream(resource stream)</h2>
278 <p>Set the resource to be sent.</p>
279 <h2 id="HTTPi_Response_getStream">resource HTTPi_Response::getStream()</h2>
280 <p>Get the previously set resource to be sent.</p>
281 <h2 id="HTTPi_Response_setFile">bool HTTPi_Response::setFile(string file)</h2>
282 <p>Set the file to be sent.</p>
283 <h2 id="HTTPi_Response_getFile">string HTTPi_Response::getFile()</h2>
284 <p>Get the previously set file to be sent.</p>
285 <h2 id="HTTPi_Response_send">bool HTTPi_Response::send()</h2>
286 <p>Finally send the entity.<br />
287 <br />
288 Example:</p><pre><blockquote><code><span style="color: #000000"><br />
289 <span style="color: #0000BB">&lt;?php<br />$r </span><span style="color: #007700">= new </span><span style="color: #0000BB">HTTPi_Response</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setFile</span><span style="color: #007700">(</span><span style="color: #DD0000">'../hidden/contract.pdf'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setContentType</span><span style="color: #007700">(</span><span style="color: #DD0000">'application/pdf'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">send</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span><br />
290 </span><br />
291 </code></blockquote><br />
292 <br />
293 </pre></p>
294 <h2 id="HTTPi_Request___construct">void HTTPi_Request::__construct([string url[, long request_method = HTTP_GET]])</h2>
295 <p>Instantiate a new HTTPi_Request object which can be used to issue HEAD, GET<br />
296 and POST (including posting files) HTTP requests.</p>
297 <h2 id="HTTPi_Request___destruct">void HTTPi_Request::__destruct()</h2>
298 <p>Destroys the HTTPi_Request object.</p>
299 <h2 id="HTTPi_Request_setOptions">bool HTTPi_Request::setOptions(array options)</h2>
300 <p>Set the request options to use. See http_get() for a full list of available options.</p>
301 <h2 id="HTTPi_Request_getOptions">array HTTPi_Request::getOptions()</h2>
302 <p>Get current set options.</p>
303 <h2 id="HTTPi_Request_setURL">bool HTTPi_Request::setURL(string url)</h2>
304 <p>Set the request URL.</p>
305 <h2 id="HTTPi_Request_getURL">string HTTPi_Request::getUrl()</h2>
306 <p>Get the previously set request URL.</p>
307 <h2 id="HTTPi_Request_setMethod">bool HTTPi_Request::setMethod(long request_method)</h2>
308 <p>Set the request methods; one of the <tt>HTTP_HEAD</tt>, <tt>HTTP_GET</tt> or<br />
309 <tt>HTTP_POST</tt> constants.</p>
310 <h2 id="HTTPi_Request_getMethod">long HTTPi_Request::getMethod()</h2>
311 <p>Get the previously set request method.</p>
312 <h2 id="HTTPi_Request_setContentType">bool HTTPi_Request::setContentType(string content_type)</h2>
313 <p>Set the content type the post request should have.<br />
314 Use this only if you know what you're doing.</p>
315 <h2 id="HTTPi_Request_getContentType">string HTTPi_Request::getContentType()</h2>
316 <p>Get the previously content type.</p>
317 <h2 id="HTTPi_Request_setQueryData">bool HTTPi_Request::setQueryData(mixed query_data)</h2>
318 <p>Set the URL query parameters to use.<br />
319 Overwrites previously set query parameters.<br />
320 Affects any request types.</p>
321 <h2 id="HTTPi_Request_getQueryData">string HTTPi_Request::getQueryData()</h2>
322 <p>Get the current query data in form of an urlencoded query string.</p>
323 <h2 id="HTTPi_Request_addQueryData">bool HTTPi_Request::addQueryData(array query_params)</h2>
324 <p>Add parameters to the query parameter list.<br />
325 Affects any request type.</p>
326 <h2 id="HTTPi_Request_unsetQueryData">void HTTPi_Request::unsetQueryData()</h2>
327 <p>Clean the query parameters.<br />
328 Affects any request type.</p>
329 <h2 id="HTTPi_Request_addPostData">bool HTTPi_Request::addPostData(array post_data)</h2>
330 <p>Adds POST data entries.<br />
331 Affects only POST requests.</p>
332 <h2 id="HTTPi_Request_setPostData">bool HTTPi_Request::setPostData(array post_data)</h2>
333 <p>Set the POST data entries.<br />
334 Overwrites previously set POST data.<br />
335 Affects only POST requests.</p>
336 <h2 id="HTTPi_Request_getPostData">array HTTPi_Request::getPostData()</h2>
337 <p>Get previously set POST data.</p>
338 <h2 id="HTTPi_Request_unsetPostData">void HTTPi_Request::unsetPostData()</h2>
339 <p>Clean POST data entires.<br />
340 Affects only POST requests.</p>
341 <h2 id="HTTPi_Request_addPostFile">bool HTTPi_Request::addPostFile(string name, string file[, string content_type = "application/x-octetstream"])</h2>
342 <p>Add a file to the POST request.<br />
343 Affects only POST requests.</p>
344 <h2 id="HTTPi_Request_getPostFiles">array HTTPi_Request::getPostFiles()</h2>
345 <p>Get all previously added POST files.</p>
346 <h2 id="HTTPi_Request_unsetPostFiles">void HTTPi_Request::unsetPostFiles()</h2>
347 <p>Unset the POST files list.<br />
348 Affects only POST requests.</p>
349 <h2 id="HTTPi_Request_getResponseData">array HTTPi_Request::getResponseData()</h2>
350 <p>Get all response data after the request has been sent.</p>
351 <h2 id="HTTPi_Request_getResponseHeader">string HTTPi_Request::getResponseHeader([string name])</h2>
352 <p>Get response header(s) after the request has been sent.</p>
353 <h2 id="HTTPi_Request_getResponseBody">string HTTPi_Request::getResponseBody()</h2>
354 <p>Get the response body after the request has been sent.</p>
355 <h2 id="HTTPi_Request_getResponseCode">int HTTPi_Request::getResponseCode()</h2>
356 <p>Get the response code after the request has been sent.</p>
357 <h2 id="HTTPi_Request_getResponseInfo">array HTTPi_Request::getResponseInfo([string name])</h2>
358 <p>Get response info after the request has been sent.<br />
359 See http_get() for a full list of returned info.</p>
360 <h2 id="HTTPi_Request_send">bool HTTPi_Request::send()</h2>
361 <p>Send the HTTP request.<br />
362 <br />
363 GET example:</p><pre><blockquote><code><span style="color: #000000"><br />
364 <span style="color: #0000BB">&lt;?php<br />$r </span><span style="color: #007700">= new </span><span style="color: #0000BB">HTTPi_Request</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://example.com/feed.rss'</span><span style="color: #007700">, </span><span style="color: #0000BB">HTTP_GET</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setOptions</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'lastmodified' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">filemtime</span><span style="color: #007700">(</span><span style="color: #DD0000">'local.rss'</span><span style="color: #007700">)));<br /></span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addQueryData</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'category' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">3</span><span style="color: #007700">));<br />if (</span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">send</span><span style="color: #007700">() &amp;&amp; </span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getResponseCode</span><span style="color: #007700">() == </span><span style="color: #0000BB">200</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">file_put_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'local.rss'</span><span style="color: #007700">, </span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getResponseBody</span><span style="color: #007700">());<br />}<br /></span><span style="color: #0000BB">?&gt;</span><br />
365 </span><br />
366 </code></blockquote></pre><p>POST example:</p><pre><blockquote><code><span style="color: #000000"><br />
367 <span style="color: #0000BB">&lt;?php<br />$r </span><span style="color: #007700">= new </span><span style="color: #0000BB">HTTPi_Request</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://example.com/form.php'</span><span style="color: #007700">, </span><span style="color: #0000BB">HTTP_POST</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setOptions</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'cookies' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">'lang' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'de'</span><span style="color: #007700">)));<br /></span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addPostData</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'user' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'mike'</span><span style="color: #007700">, </span><span style="color: #DD0000">'pass' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'s3c|r3t'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addPostFile</span><span style="color: #007700">(</span><span style="color: #DD0000">'image'</span><span style="color: #007700">, </span><span style="color: #DD0000">'profile.jpg'</span><span style="color: #007700">, </span><span style="color: #DD0000">'image/jpeg'</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">send</span><span style="color: #007700">()) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getResponseBody</span><span style="color: #007700">();<br />}<br /></span><span style="color: #0000BB">?&gt;</span><br />
368 </span><br />
369 </code></blockquote><br />
370 <br />
371 </pre></p>
372 <hr noshade>
373 <p><b>Generated at: Mon, 7 Mar 2005 14:09:33 +0100</b></p>
374 </body>
375 </html>
376