- changelog
[m6w6/ext-http] / docs / functions.html
1 <html>
2 <head>
3 <title>Function Summary of ext/http</title>
4 <style>
5 body {
6 font-size: 80%;
7 font-family: sans-serif;
8 }
9 h2, h3 {
10 color: #339;
11 clear: both;
12 font-size: 1.2em;
13 background: #ffc;
14 padding: .2em;
15 }
16 h2.o {
17 color: #66b;
18 clear: both;
19 font-size: 1.3em;
20 background: #f0f0f0;
21 padding: .2em;
22 }
23 p {
24 margin-left: 1em;
25 }
26 pre {
27 font-size: 1.2em;
28 }
29 br {
30 display: none;
31 }
32 blockquote {
33 margin-bottom: 3em;
34 border: 1px solid #ccc;
35 background: #f0f0f0;
36 padding: 0em 1em;
37 width: auto;
38 float: left;
39 }
40 p, pre {
41 clear: both;
42 }
43 p br, pre code br {
44 display: block;
45 }
46 </style>
47 </head>
48 <body><h1>http_functions.c</h1>
49 <h2 id="http_date">string http_date([int timestamp])</h2>
50 <p>Compose a valid HTTP date regarding RFC 822/1123<br />
51 looking like: "Wed, 22 Dec 2004 11:34:47 GMT"</p>
52 <p>Takes an optional unix timestamp as parameter.<br />
53 <br />
54 Returns the HTTP date as string.</p>
55 <h2 id="http_build_uri">string http_build_uri(string url[, string proto[, string host[, int port]]])</h2>
56 <p>Build a complete URI according to the supplied parameters.</p>
57 <p>If the url is already abolute but a different proto was supplied,<br />
58 only the proto part of the URI will be updated. If url has no<br />
59 path specified, the path of the current REQUEST_URI will be taken.<br />
60 The host will be taken either from the Host HTTP header of the client<br />
61 the SERVER_NAME or just localhost if prior are not available.<br />
62 If a port is pecified in either the url or as sperate parameter,<br />
63 it will be added if it differs from te default port for HTTP(S).</p>
64 <p>Returns the absolute URI as string.</p>
65 <p>Examples:</p><pre><blockquote><code><span style="color: #000000"><br />
66 <span style="color: #0000BB">&lt;?php<br />$uri&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">http_build_uri</span><span style="color: #007700">(</span><span style="color: #DD0000">"page.php"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"https"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">488</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span><br />
67 </span></code></blockquote></p>
68 <p></pre></p>
69 <h2 id="http_negotiate_language">string http_negotiate_language(array supported[, array &result])</h2>
70 <p>This function negotiates the clients preferred language based on its<br />
71 Accept-Language HTTP header. The qualifier is recognized and languages <br />
72 without qualifier are rated highest. The qualifier will be decreased by<br />
73 10% for partial matches (i.e. matching primary language).</p>
74 <p>Expects an array as parameter cotaining the supported languages as values.<br />
75 If the optional second parameter is supplied, it will be filled with an<br />
76 array containing the negotiation results.</p>
77 <p>Returns the negotiated language or the default language (i.e. first array entry) <br />
78 if none match.</p>
79 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
80 <span style="color: #0000BB">&lt;?php<br />$langs&nbsp;</span><span style="color: #007700">=&nbsp;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">//&nbsp;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 /><br />include&nbsp;</span><span style="color: #DD0000">'./langs/'</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">http_negotiate_language</span><span style="color: #007700">(</span><span style="color: #0000BB">$langs</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;.</span><span style="color: #DD0000">'.php'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span><br />
81 </span></code></blockquote></p>
82 <p></pre></p>
83 <h2 id="http_negotiate_charset">string http_negotiate_charset(array supported[, array &result])</h2>
84 <p>This function negotiates the clients preferred charset based on its<br />
85 Accept-Charset HTTP header. The qualifier is recognized and charsets <br />
86 without qualifier are rated highest.</p>
87 <p>Expects an array as parameter cotaining the supported charsets as values.<br />
88 If the optional second parameter is supplied, it will be filled with an<br />
89 array containing the negotiation results.</p>
90 <p>Returns the negotiated charset or the default charset (i.e. first array entry) <br />
91 if none match.</p>
92 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
93 <span style="color: #0000BB">&lt;?php<br />$charsets&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'iso-8859-1'</span><span style="color: #007700">,&nbsp;</span><span style="color: #FF8000">//&nbsp;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 /><br /></span><span style="color: #0000BB">$pref&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">http_negotiate_charset</span><span style="color: #007700">(</span><span style="color: #0000BB">$charsets</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">strcmp</span><span style="color: #007700">(</span><span style="color: #0000BB">$pref</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'iso-8859-1'</span><span style="color: #007700">))&nbsp;{<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">,&nbsp;</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">,&nbsp;</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 /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span><br />
94 </span></code></blockquote></p>
95 <p></pre></p>
96 <h2 id="http_send_status">bool http_send_status(int status)</h2>
97 <p>Send HTTP status code.</p>
98 <p>Expects an HTTP status code as parameter.</p>
99 <p>Returns TRUE on success or FALSE on failure.</p>
100 <h2 id="http_send_last_modified">bool http_send_last_modified([int timestamp])</h2>
101 <p>Send a "Last-Modified" header with a valid HTTP date.</p>
102 <p>Accepts a unix timestamp, converts it to a valid HTTP date and<br />
103 sends it as "Last-Modified" HTTP header. If timestamp is<br />
104 omitted, the current time will be sent.</p>
105 <p>Returns TRUE on success or FALSE on failure.</p>
106 <h2 id="http_send_content_type">bool http_send_content_type([string content_type = 'application/x-octetstream'])</h2>
107 <p>Send the Content-Type of the sent entity. This is particularly important<br />
108 if you use the http_send() API.</p>
109 <p>Accepts an optional string parameter containing the desired content type <br />
110 (primary/secondary).</p>
111 <p>Returns TRUE on success or FALSE on failure.</p>
112 <h2 id="http_send_content_disposition">bool http_send_content_disposition(string filename[, bool inline = false])</h2>
113 <p>Send the Content-Disposition. The Content-Disposition header is very useful<br />
114 if the data actually sent came from a file or something similar, that should<br />
115 be "saved" by the client/user (i.e. by browsers "Save as..." popup window).</p>
116 <p>Expects a string parameter specifying the file name the "Save as..." dialogue<br />
117 should display. Optionally accepts a bool parameter, which, if set to true<br />
118 and the user agent knows how to handle the content type, will probably not<br />
119 cause the popup window to be shown.</p>
120 <p>Returns TRUE on success or FALSE on failure.</p>
121 <h2 id="http_match_modified">bool http_match_modified([int timestamp[, bool for_range = false]])</h2>
122 <p>Matches the given unix timestamp against the clients "If-Modified-Since" <br />
123 resp. "If-Unmodified-Since" HTTP headers.</p>
124 <p>Accepts a unix timestamp which should be matched. Optionally accepts an<br />
125 additional bool parameter, which if set to true will check the header <br />
126 usually used to validate HTTP ranges. If timestamp is omitted, the<br />
127 current time will be used.</p>
128 <p>Returns TRUE if timestamp represents an earlier date than the header,<br />
129 else FALSE.</p>
130 <h2 id="http_match_etag">bool http_match_etag(string etag[, bool for_range = false])</h2>
131 <p>Matches the given ETag against the clients "If-Match" resp. <br />
132 "If-None-Match" HTTP headers.</p>
133 <p>Expects a string parameter containing the ETag to compare. Optionally<br />
134 accepts a bool parameter, which, if set to true, will check the header<br />
135 usually used to validate HTTP ranges.</p>
136 <p>Retuns TRUE if ETag matches or the header contained the asterisk ("*"),<br />
137 else FALSE.</p>
138 <h2 id="http_cache_last_modified">bool http_cache_last_modified([int timestamp_or_expires]])</h2>
139 <p>Attempts to cache the sent entity by its last modification date.</p>
140 <p>Accepts a unix timestamp as parameter which is handled as follows:</p>
141 <p>If timestamp_or_expires is greater than 0, it is handled as timestamp<br />
142 and will be sent as date of last modification. If it is 0 or omitted,<br />
143 the current time will be sent as Last-Modified date. If it's negative,<br />
144 it is handled as expiration time in seconds, which means that if the<br />
145 requested last modification date is not between the calculated timespan,<br />
146 the Last-Modified header is updated and the actual body will be sent.</p>
147 <p>Returns FALSE on failure, or *exits* with "304 Not Modified" if the entity is cached.</p>
148 <p>A log entry will be written to the cache log if the INI entry<br />
149 http.cache_log is set and the cache attempt was successful.</p>
150 <h2 id="http_cache_etag">bool http_cache_etag([string etag])</h2>
151 <p>Attempts to cache the sent entity by its ETag, either supplied or generated <br />
152 by the hash algorythm specified by the INI setting "http.etag_mode".</p>
153 <p>If the clients "If-None-Match" header matches the supplied/calculated<br />
154 ETag, the body is considered cached on the clients side and<br />
155 a "304 Not Modified" status code is issued.</p>
156 <p>Returns FALSE on failure, or *exits* with "304 Not Modified" if the entity is cached.</p>
157 <p>A log entry is written to the cache log if the INI entry<br />
158 "http.cache_log" is set and the cache attempt was successful.</p>
159 <h2 id="ob_etaghandler">string ob_etaghandler(string data, int mode)</h2>
160 <p>For use with ob_start(). Output buffer handler generating an ETag with<br />
161 the hash algorythm specified with the INI setting "http.etag_mode".</p>
162 <h2 id="http_throttle">void http_throttle(double sec[, int bytes = 2097152])</h2>
163 <p>Sets the throttle delay and send buffer size for use with http_send() API.<br />
164 Provides a basic throttling mechanism, which will yield the current process<br />
165 resp. thread until the entity has been completely sent, though.</p>
166 <p>Note: This doesn't really work with the FastCGI SAPI.</p>
167 <p>Expects a double parameter specifying the seconds too sleep() after<br />
168 each chunk sent. Additionally accepts an optional int parameter<br />
169 representing the chunk size in bytes.</p>
170 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
171 <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;~&nbsp;20&nbsp;kbyte/s<br />#&nbsp;http_throttle(1,&nbsp;20000);<br />#&nbsp;http_throttle(0.5,&nbsp;10000);<br />#&nbsp;http_throttle(0.1,&nbsp;2000);<br /></span><span style="color: #0000BB">http_send_file</span><span style="color: #007700">(</span><span style="color: #DD0000">'document.pdf'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span><br />
172 </span></code></blockquote></p>
173 <p></pre></p>
174 <h2 id="http_redirect">void http_redirect([string url[, array params[, bool session = false[, int status = 302]]]])</h2>
175 <p>Redirect to the given url.<br />
176 <br />
177 The supplied url will be expanded with http_build_uri(), the params array will<br />
178 be treated with http_build_query() and the session identification will be appended<br />
179 if session is true.</p>
180 <p>The HTTP response code will be set according to status.<br />
181 You can use one of the following constants for convenience:<br />
182 - HTTP_REDIRECT 302 Found<br />
183 - HTTP_REDIRECT_PERM 301 Moved Permanently<br />
184 - HTTP_REDIRECT_POST 303 See Other<br />
185 - HTTP_REDIRECT_TEMP 307 Temporary Redirect</p>
186 <p>Please see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3<br />
187 for which redirect response code to use in which situation.</p>
188 <p>To be RFC compliant, "Redirecting to <a>URI</a>." will be displayed,<br />
189 if the client doesn't redirect immediatly, and the request method was<br />
190 another one than HEAD.</p>
191 <p>Returns FALSE on failure, or *exits* on success.</p>
192 <p>A log entry will be written to the redirect log, if the INI entry<br />
193 "http.redirect_log" is set and the redirect attempt was successful.</p>
194 <h2 id="http_send_data">bool http_send_data(string data)</h2>
195 <p>Sends raw data with support for (multiple) range requests.</p>
196 <p>Retursn TRUE on success, or FALSE on failure.</p>
197 <h2 id="http_send_file">bool http_send_file(string file)</h2>
198 <p>Sends a file with support for (multiple) range requests.</p>
199 <p>Expects a string parameter referencing the file to send.</p>
200 <p>Returns TRUE on success, or FALSE on failure.</p>
201 <h2 id="http_send_stream">bool http_send_stream(resource stream)</h2>
202 <p>Sends an already opened stream with support for (multiple) range requests.</p>
203 <p>Expects a resource parameter referncing the stream to read from.</p>
204 <p>Returns TRUE on success, or FALSE on failure.</p>
205 <h2 id="http_chunked_decode">string http_chunked_decode(string encoded)</h2>
206 <p>Decodes a string that was HTTP-chunked encoded.</p>
207 <p>Expects a chunked encoded string as parameter.</p>
208 <p>Returns the decoded string on success or FALSE on failure.</p>
209 <h2 id="http_parse_message">object http_parse_message(string message)</h2>
210 <p>Parses (a) http_message(s) into a simple recursive object structure.</p>
211 <p>Expects a string parameter containing a single HTTP message or<br />
212 several consecutive HTTP messages.</p>
213 <p>Returns an hierachical object structure of the parsed messages.</p>
214 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
215 <span style="color: #0000BB">&lt;?php<br />print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">http_parse_message</span><span style="color: #007700">(</span><span style="color: #0000BB">http_get</span><span style="color: #007700">(</span><span style="color: #0000BB">URL</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'redirect'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">)));<br /><br /></span><span style="color: #0000BB">stdClass&nbsp;object<br /></span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style="color: #0000BB">type</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">2<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">httpVersion</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">1.1<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">responseCode</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">200<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">headers</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;Array&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style="color: #0000BB">Content</span><span style="color: #007700">-</span><span style="color: #0000BB">Length</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">3<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">Server</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">Apache<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style="color: #0000BB">body</span><span style="color: #007700">]&nbsp;&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">Hi</span><span style="color: #007700">!<br />&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style="color: #0000BB">parentMessage</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">stdClass&nbsp;object<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style="color: #0000BB">type</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">2<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">httpVersion</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">1.1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">responseCode</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">302<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">headers</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;Array&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style="color: #0000BB">Content</span><span style="color: #007700">-</span><span style="color: #0000BB">Length</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">0<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">Location</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style="color: #0000BB">body</span><span style="color: #007700">]&nbsp;&nbsp;=&gt;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style="color: #0000BB">parentMessage</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;...<br />&nbsp;&nbsp;&nbsp;&nbsp;)<br />)<br /></span><span style="color: #0000BB">?&gt;</span><br />
216 </span></code></blockquote></p>
217 <p></pre></p>
218 <h2 id="http_parse_headers">array http_parse_headers(string header)</h2>
219 <p>Parses HTTP headers into an associative array.</p>
220 <p>Expects a string parameter containing HTTP headers.</p>
221 <p>Returns an array on success, or FALSE on failure.</p>
222 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
223 <span style="color: #0000BB">&lt;?php<br />$headers&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"content-type:&nbsp;text/html;&nbsp;charset=UTF-8\r\n"</span><span style="color: #007700">.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"Server:&nbsp;Funky/1.0\r\n"</span><span style="color: #007700">.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"Set-Cookie:&nbsp;foo=bar\r\n"</span><span style="color: #007700">.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"Set-Cookie:&nbsp;baz=quux\r\n"</span><span style="color: #007700">.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"Folded:&nbsp;works\r\n\ttoo\r\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">http_parse_headers</span><span style="color: #007700">(</span><span style="color: #0000BB">$headers</span><span style="color: #007700">));<br /><br />Array<br />(<br />&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style="color: #0000BB">Content</span><span style="color: #007700">-</span><span style="color: #0000BB">Type</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">text</span><span style="color: #007700">/</span><span style="color: #0000BB">html</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">chatset</span><span style="color: #007700">=</span><span style="color: #0000BB">UTF</span><span style="color: #007700">-</span><span style="color: #0000BB">8<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">Server</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">Funky</span><span style="color: #007700">/</span><span style="color: #0000BB">1.0<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">Set</span><span style="color: #007700">-</span><span style="color: #0000BB">Cookie</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;Array<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style="color: #0000BB">0</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">foo</span><span style="color: #007700">=</span><span style="color: #0000BB">bar<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">baz</span><span style="color: #007700">=</span><span style="color: #0000BB">quux<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style="color: #0000BB">Folded</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">works<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;too&nbsp;<br />?&gt;</span><br />
224 </span></code></blockquote></p>
225 <p></pre></p>
226 <h2 id="http_get_request_headers">array http_get_request_headers(void)</h2>
227 <p>Get a list of incoming HTTP headers.</p>
228 <p>Returns an associative array of incoming request headers.</p>
229 <h2 id="http_get_request_body">string http_get_request_body(void)</h2>
230 <p>Get the raw request body (e.g. POST or PUT data).</p>
231 <p>Returns NULL when using the CLI SAPI.</p>
232 <h2 id="http_match_request_header">bool http_match_request_header(string header, string value[, bool match_case = false])</h2>
233 <p>Match an incoming HTTP header.</p>
234 <p>Expects two string parameters representing the header name (case-insensitive)<br />
235 and the header value that should be compared. The case sensitivity of the<br />
236 header value depends on the additional optional bool parameter accepted.</p>
237 <p>Returns TRUE if header value matches, else FALSE.</p>
238 <h2 id="http_get">string http_get(string url[, array options[, array &info]])</h2>
239 <p>Performs an HTTP GET request on the supplied url.</p>
240 <p>The second parameter, if set, is expected to be an associative<br />
241 array where the following keys will be recognized:</p><pre> - redirect: int, whether and how many redirects to follow<br />
242 - unrestrictedauth: bool, whether to continue sending credentials on<br />
243 redirects to a different host<br />
244 - proxyhost: string, proxy host in "host[:port]" format<br />
245 - proxyport: int, use another proxy port as specified in proxyhost<br />
246 - proxyauth: string, proxy credentials in "user:pass" format<br />
247 - proxyauthtype: int, HTTP_AUTH_BASIC and/or HTTP_AUTH_NTLM<br />
248 - httpauth: string, http credentials in "user:pass" format<br />
249 - httpauthtype: int, HTTP_AUTH_BASIC, DIGEST and/or NTLM<br />
250 - compress: bool, whether to allow gzip/deflate content encoding<br />
251 (defaults to true)<br />
252 - port: int, use another port as specified in the url<br />
253 - referer: string, the referer to sends<br />
254 - useragent: string, the user agent to send<br />
255 (defaults to PECL::HTTP/version (PHP/version)))<br />
256 - headers: array, list of custom headers as associative array<br />
257 like array("header" => "value")<br />
258 - cookies: array, list of cookies as associative array<br />
259 like array("cookie" => "value")<br />
260 - cookiestore: string, path to a file where cookies are/will be stored<br />
261 - resume: int, byte offset to start the download from;<br />
262 if the server supports ranges<br />
263 - maxfilesize: int, maximum file size that should be downloaded;<br />
264 has no effect, if the size of the requested entity is not known<br />
265 - lastmodified: int, timestamp for If-(Un)Modified-Since header<br />
266 - timeout: int, seconds the request may take<br />
267 - connecttimeout: int, seconds the connect may take<br />
268 - onprogress: mixed, progress callback<br />
269 </pre></p>
270 <p>The optional third parameter will be filled with some additional information<br />
271 in form af an associative array, if supplied, like the following example:</p><pre><blockquote><code><span style="color: #000000"><br />
272 <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">array&nbsp;(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'effective_url'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'http://localhost'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'response_code'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">403</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'total_time'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0.017</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'namelookup_time'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0.013</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'connect_time'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0.014</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'pretransfer_time'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0.014</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'size_upload'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'size_download'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">202</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'speed_download'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">11882</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'speed_upload'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'header_size'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">145</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'request_size'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">62</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'ssl_verifyresult'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'filetime'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;-</span><span style="color: #0000BB">1</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'content_length_download'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">202</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'content_length_upload'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'starttransfer_time'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0.017</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'content_type'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/html;&nbsp;charset=iso-8859-1'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'redirect_time'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'redirect_count'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'http_connectcode'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'httpauth_avail'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'proxyauth_avail'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />)<br /></span><span style="color: #0000BB">?&gt;</span><br />
273 </span></code></blockquote></p>
274 <p></pre></p>
275 <p>Returns the HTTP response(s) as string on success, or FALSE on failure.</p>
276 <h2 id="http_head">string http_head(string url[, array options[, array &info]])</h2>
277 <p>Performs an HTTP HEAD request on the supplied url.</p>
278 <p>See http_get() for a full list of available parameters and options.</p>
279 <p>Returns the HTTP response as string on success, or FALSE on failure.</p>
280 <h2 id="http_post_data">string http_post_data(string url, string data[, array options[, array &info]])</h2>
281 <p>Performs an HTTP POST requeston the supplied url.</p>
282 <p>Expects a string as second parameter containing the pre-encoded post data.<br />
283 See http_get() for a full list of available parameters and options.<br />
284 <br />
285 Returns the HTTP response(s) as string on success, or FALSE on failure.</p>
286 <h2 id="http_post_fields">string http_post_fields(string url, array data[, array files[, array options[, array &info]]])</h2>
287 <p>Performs an HTTP POST request on the supplied url.</p>
288 <p>Expecrs an associative array as second parameter, which will be<br />
289 www-form-urlencoded. See http_get() for a full list of available options.</p>
290 <p>Returns the HTTP response(s) as string on success, or FALSE on failure.</p>
291 <h2 id="http_put_file">string http_put_file(string url, string file[, array options[, array &info]])</h2>
292 <p>Performs an HTTP PUT request on the supplied url.</p>
293 <p>Expects the second parameter to be a string referncing the file to upload.<br />
294 See http_get() for a full list of available options.</p>
295 <p>Returns the HTTP response(s) as string on success, or FALSE on failure.</p>
296 <h2 id="http_put_stream">string http_put_stream(string url, resource stream[, array options[, array &info]])</h2>
297 <p>Performs an HTTP PUT request on the supplied url.</p>
298 <p>Expects the second parameter to be a resource referencing an already <br />
299 opened stream, from which the data to upload should be read.<br />
300 See http_get() for a full list of available options.</p>
301 <p>Returns the HTTP response(s) as string on success. or FALSE on failure.</p>
302 <h2 id="http_request_method_register">int http_request_method_register(string method)</h2>
303 <p>Register a custom request method.</p>
304 <p>Expects a string parameter containing the request method name to register.</p>
305 <p>Returns the ID of the request method on success, or FALSE on failure.</p>
306 <h2 id="http_request_method_unregister">bool http_request_method_unregister(mixed method)</h2>
307 <p>Unregister a previously registered custom request method.</p>
308 <p>Expects either the request method name or ID.</p>
309 <p>Returns TRUE on success, or FALSE on failure.</p>
310 <h2 id="http_request_method_exists">long http_request_method_exists(mixed method)</h2>
311 <p>Check if a request method is registered (or available by default).</p>
312 <p>Expects either the request method name or ID as parameter.</p>
313 <p>Returns TRUE if the request method is known, else FALSE.</p>
314 <h2 id="http_request_method_name">string http_request_method_name(int method)</h2>
315 <p>Get the literal string representation of a standard or registered request method.</p>
316 <p>Expects the request method ID as parameter.</p>
317 <p>Returns the request method name as string on success, or FALSE on failure.</p>
318 <h2 id="http_build_query">string http_build_query(mixed formdata [, string prefix[, string arg_separator]])</h2>
319 <p>Generates a form-encoded query string from an associative array or object.</p>
320 <hr noshade>
321 <h1>http_message_object.c</h1>
322 <h2 id="HttpMessage" class="o">HttpMessage</h2>
323 <h3 id="HttpMessage___construct">void HttpMessage::__construct([string message])</h3>
324 <p>Instantiate a new HttpMessage object.</p>
325 <p>Accepts an optional string parameter containing a single or several <br />
326 consecutive HTTP messages. The constructed object will actually <br />
327 represent the *last* message of the passed string. If there were<br />
328 prior messages, those can be accessed by HttpMessage::getParentMessage().</p>
329 <p>Throws HttpMalformedHeaderException.</p>
330 <h3 id="HttpMessage_fromString">static HttpMessage HttpMessage::fromString(string raw_message)</h3>
331 <p>Create an HttpMessage object from a string. Kind of a static constructor.</p>
332 <p>Expects a string parameter containing a sinlge or several consecutive<br />
333 HTTP messages.</p>
334 <p>Returns an HttpMessage object on success or NULL on failure.</p>
335 <p>Throws HttpMalformedHeadersException.</p>
336 <h3 id="HttpMessage_getBody">string HttpMessage::getBody()</h3>
337 <p>Get the body of the parsed HttpMessage.</p>
338 <p>Returns the message body as string.</p>
339 <h3 id="HttpMessage_setBody">void HttpMessage::setBody(string body)</h3>
340 <p>Set the body of the HttpMessage.<br />
341 NOTE: Don't forget to update any headers accordingly.</p>
342 <p>Expects a string parameter containing the new body of the message.</p>
343 <h3 id="HttpMessage_getHeaders">array HttpMessage::getHeaders()</h3>
344 <p>Get Message Headers.</p>
345 <p>Returns an associative array containing the messages HTTP headers.</p>
346 <h3 id="HttpMessage_setHeaders">void HttpMessage::setHeaders(array headers)</h3>
347 <p>Sets new headers.</p>
348 <p>Expects an associative array as parameter containing the new HTTP headers,<br />
349 which will replace *all* previous HTTP headers of the message.</p>
350 <h3 id="HttpMessage_addHeaders">void HttpMessage::addHeaders(array headers[, bool append = false])</h3>
351 <p>Add headers. If append is true, headers with the same name will be separated, else overwritten.</p>
352 <p>Expects an associative array as parameter containing the additional HTTP headers<br />
353 to add to the messages existing headers. If the optional bool parameter is true,<br />
354 and a header with the same name of one to add exists already, this respective<br />
355 header will be converted to an array containing both header values, otherwise<br />
356 it will be overwritten with the new header value.</p>
357 <h3 id="HttpMessage_getType">int HttpMessage::getType()</h3>
358 <p>Get Message Type. (HTTP_MSG_NONE|HTTP_MSG_REQUEST|HTTP_MSG_RESPONSE)</p>
359 <p>Returns the HttpMessage::TYPE.</p>
360 <h3 id="HttpMessage_setType">void HttpMessage::setType(int type)</h3>
361 <p>Set Message Type. (HTTP_MSG_NONE|HTTP_MSG_REQUEST|HTTP_MSG_RESPONSE)</p>
362 <p>Exptects an int parameter, the HttpMessage::TYPE.</p>
363 <h3 id="HttpMessage_getResponseCode">int HttpMessage::getResponseCode()</h3>
364 <p>Get the Response Code of the Message.</p>
365 <p>Returns the HTTP response code if the message is of type <br />
366 HttpMessage::TYPE_RESPONSE, else FALSE.</p>
367 <h3 id="HttpMessage_setResponseCode">bool HttpMessage::setResponseCode(int code)</h3>
368 <p>Set the response code of an HTTP Response Message.</p>
369 <p>Expects an int parameter with the HTTP response code.</p>
370 <p>Returns TRUE on success, or FALSE if the message is not of type<br />
371 HttpMessage::TYPE_RESPONSE or the response code is out of range (100-510).</p>
372 <h3 id="HttpMessage_getRequestMethod">string HttpMessage::getRequestMethod()</h3>
373 <p>Get the Request Method of the Message.</p>
374 <p>Returns the request method name on success, or FALSE if the message is<br />
375 not of type HttpMessage::TYPE_REQUEST.</p>
376 <h3 id="HttpMessage_setRequestMethod">bool HttpMessage::setRequestMethod(string method)</h3>
377 <p>Set the Request Method of the HTTP Message.</p>
378 <p>Expects a string parameter containing the request method name.</p>
379 <p>Returns TRUE on success, or FALSE if the message is not of type<br />
380 HttpMessage::TYPE_REQUEST or an invalid request method was supplied.</p>
381 <h3 id="HttpMessage_getRequestUri">string HttpMessage::getRequestUri()</h3>
382 <p>Get the Request URI of the Message.</p>
383 <p>Returns the request uri as string on success, or FALSE if the message<br />
384 is not of type HttpMessage::TYPE_REQUEST.</p>
385 <h3 id="HttpMessage_setRequestUri">bool HttpMessage::setRequestUri(string URI)</h3>
386 <p>Set the Request URI of the HTTP Message.</p>
387 <p>Expects a string parameters containing the request uri.</p>
388 <p>Returns TRUE on success, or FALSE if the message is not of type<br />
389 HttpMessage::TYPE_REQUEST or supplied URI was empty.</p>
390 <h3 id="HttpMessage_getHttpVersion">string HttpMessage::getHttpVersion()</h3>
391 <p>Get the HTTP Protocol Version of the Message.</p>
392 <p>Returns the HTTP protocol version as string.</p>
393 <h3 id="HttpMessage_setHttpVersion">bool HttpMessage::setHttpVersion(string version)</h3>
394 <p>Set the HTTP Protocol version of the Message.</p>
395 <p>Expects a string parameter containing the HTTP protocol version.</p>
396 <p>Returns TRUE on success, or FALSE if supplied version is out of range (1.0/1.1).</p>
397 <h3 id="HttpMessage_getParentMessage">HttpMessage HttpMessage::getParentMessage()</h3>
398 <p>Get parent Message.</p>
399 <p>Returns the parent HttpMessage on success, or NULL if there's none.</p>
400 <h3 id="HttpMessage_send">bool HttpMessage::send()</h3>
401 <p>Send the Message according to its type as Response or Request.<br />
402 This provides limited functionality compared to HttpRequest and HttpResponse.</p>
403 <p>Returns TRUE on success, or FALSE on failure.</p>
404 <h3 id="HttpMessage_toString">string HttpMessage::toString([bool include_parent = false])</h3>
405 <p>Get the string representation of the Message.</p>
406 <p>Accepts a bool parameter which specifies whether the returned string<br />
407 should also contain any parent messages.</p>
408 <p>Returns the full message as string.</p>
409 <hr noshade>
410 <h1>http_request_object.c</h1>
411 <h2 id="HttpRequest" class="o">HttpRequest</h2>
412 <h3 id="HttpRequest___construct">void HttpRequest::__construct([string url[, int request_method = HTTP_METH_GET]])</h3>
413 <p>Instantiate a new HttpRequest object.</p>
414 <p>Accepts a string as optional parameter containing the target request url.<br />
415 Additianally accepts an optional int parameter specifying the request method<br />
416 to use.</p>
417 <p>Throws HttpException.</p>
418 <h3 id="HttpRequest___destruct">void HttpRequest::__destruct()</h3>
419 <p>Destroys the HttpRequest object.</p>
420 <h3 id="HttpRequest_setOptions">bool HttpRequest::setOptions([array options])</h3>
421 <p>Set the request options to use. See http_get() for a full list of available options.</p>
422 <p>Accepts an array as optional parameters, wich values will overwrite the <br />
423 currently set request options. If the parameter is empty or mitted,<br />
424 the optoions of the HttpRequest object will be reset.</p>
425 <p>Returns TRUE on success, or FALSE on failure.</p>
426 <h3 id="HttpRequest_getOptions">array HttpRequest::getOptions()</h3>
427 <p>Get currently set options.</p>
428 <p>Returns an associative array containing currently set options.</p>
429 <h3 id="HttpRequest_setSslOptions">bool HttpRequest::setSslOptions([array options])</h3>
430 <p>Set SSL options.</p>
431 <p>Accepts an associative array as parameter containing any SSL specific options.<br />
432 If the parameter is empty or omitted, the SSL options will be reset.</p>
433 <p>Returns TRUE on success, or FALSE on failure.</p>
434 <h3 id="HttpRequest_addSslOptions">bool HttpRequest::addSslOptions(array options)</h3>
435 <p>Set additional SSL options.</p>
436 <p>Expects an associative array as parameter containing additional SSL specific options.</p>
437 <p>Returns TRUE on success, or FALSE on failure.</p>
438 <h3 id="HttpRequest_getSslOptions">array HttpRequest::getSslOtpions()</h3>
439 <p>Get previously set SSL options.</p>
440 <p>Returns an associative array containing any previously set SSL options.</p>
441 <h3 id="HttpRequest_addHeaders">bool HttpRequest::addHeaders(array headers)</h3>
442 <p>Add request header name/value pairs.</p>
443 <p>Expects an ssociative array as parameter containing additional header<br />
444 name/value pairs.</p>
445 <p>Returns TRUE on success, or FALSE on failure.</p>
446 <h3 id="HttpRequest_setHeaders">bool HttpRequest::setHeaders([array headers])</h3>
447 <p>Set request header name/value pairs.</p>
448 <p>Accepts an associative array as parameter containing header name/value pairs.<br />
449 If the parameter is empty or omitted, all previously set headers will be unset.</p>
450 <p>Returns TRUE on success, or FALSE on failure.</p>
451 <h3 id="HttpRequest_getHeaders">array HttpRequest::getHeaders()</h3>
452 <p>Get previously set request headers.</p>
453 <p>Returns an associative array containing all currently set headers.</p>
454 <h3 id="HttpRequest_setCookies">bool HttpRequest::setCookies([array cookies])</h3>
455 <p>Set cookies.</p>
456 <p>Accepts an associative array as parameter containing cookie name/value pairs.<br />
457 If the parameter is empty or omitted, all previously set cookies will be unset.</p>
458 <p>Returns TRUE on success, or FALSE on failure.</p>
459 <h3 id="HttpRequest_addCookies">bool HttpRequest::addCookies(array cookies)</h3>
460 <p>Add cookies.</p>
461 <p>Expects an associative array as parameter containing any cookie name/value<br />
462 pairs to add.</p>
463 <p>Returns TRUE on success, or FALSE on failure.</p>
464 <h3 id="HttpRequest_getCookies">array HttpRequest::getCookies()</h3>
465 <p>Get previously set cookies.</p>
466 <p>Returns an associative array containing any previously set cookies.</p>
467 <h3 id="HttpRequest_setUrl">bool HttpRequest::setUrl(string url)</h3>
468 <p>Set the request URL.</p>
469 <p>Expects a string as parameter specifying the request url.</p>
470 <p>Returns TRUE on success, or FALSE on failure.</p>
471 <h3 id="HttpRequest_getUrl">string HttpRequest::getUrl()</h3>
472 <p>Get the previously set request URL.</p>
473 <p>Returns the currently set request url as string.</p>
474 <h3 id="HttpRequest_setMethod">bool HttpRequest::setMethod(int request_method)</h3>
475 <p>Set the request method.</p>
476 <p>Expects an int as parameter specifying the request method to use.<br />
477 In PHP 5.1+ HttpRequest::METH, otherwise the HTTP_METH constants can be used.</p>
478 <p>Returns TRUE on success, or FALSE on failure.</p>
479 <h3 id="HttpRequest_getMethod">int HttpRequest::getMethod()</h3>
480 <p>Get the previously set request method.</p>
481 <p>Returns the currently set request method.</p>
482 <h3 id="HttpRequest_setContentType">bool HttpRequest::setContentType(string content_type)</h3>
483 <p>Set the content type the post request should have.</p>
484 <p>Expects a string as parameters containing the content type of the request<br />
485 (primary/secondary).</p>
486 <p>Returns TRUE on success, or FALSE if the content type does not seem to<br />
487 contain a primary and a secondary part.</p>
488 <h3 id="HttpRequest_getContentType">string HttpRequest::getContentType()</h3>
489 <p>Get the previously content type.</p>
490 <p>Returns the previously set content type as string.</p>
491 <h3 id="HttpRequest_setQueryData">bool HttpRequest::setQueryData([mixed query_data])</h3>
492 <p>Set the URL query parameters to use, overwriting previously set query parameters.<br />
493 Affects any request types.</p>
494 <p>Accepts a string or associative array parameter containing the pre-encoded <br />
495 query string or to be encoded query fields. If the parameter is empty or<br />
496 omitted, the query data will be unset. </p>
497 <p>Returns TRUE on success, or FALSE on failure.</p>
498 <h3 id="HttpRequest_getQueryData">string HttpRequest::getQueryData()</h3>
499 <p>Get the current query data in form of an urlencoded query string.</p>
500 <p>Returns a string containing the urlencoded query.</p>
501 <h3 id="HttpRequest_addQueryData">bool HttpRequest::addQueryData(array query_params)</h3>
502 <p>Add parameters to the query parameter list, leaving previously set unchanged.<br />
503 Affects any request type.</p>
504 <p>Expects an associative array as parameter containing the query fields to add.</p>
505 <p>Returns TRUE on success, or FALSE on failure.</p>
506 <h3 id="HttpRequest_addPostFields">bool HttpRequest::addPostFields(array post_data)</h3>
507 <p>Adds POST data entries, leaving previously set unchanged, unless a<br />
508 post entry with the same name already exists. <br />
509 Affects only POST and custom requests.</p>
510 <p>Expects an associative array as parameter containing the post fields.</p>
511 <p>Returns TRUE on success, or FALSE on failure.</p>
512 <h3 id="HttpRequest_setPostFields">bool HttpRequest::setPostFields([array post_data])</h3>
513 <p>Set the POST data entries, overwriting previously set POST data.<br />
514 Affects only POST and custom requests.</p>
515 <p>Accepts an associative array as parameter containing the post fields.<br />
516 If the parameter is empty or omitted, the post data will be unset.</p>
517 <p>Returns TRUE on success, or FALSE on failure.</p>
518 <h3 id="HttpRequest_getPostFields">array HttpRequest::getPostFields()</h3>
519 <p>Get previously set POST data.</p>
520 <p>Returns the currently set post fields as associative array.</p>
521 <h3 id="HttpRequest_setRawPostData">bool HttpRequest::setRawPostData([string raw_post_data])</h3>
522 <p>Set raw post data to send, overwriting previously set raw post data. Don't <br />
523 forget to specify a content type. Affects only POST and custom requests.<br />
524 Only either post fields or raw post data can be used for each request.<br />
525 Raw post data has higher precedence and will be used even if post fields<br />
526 are set. </p>
527 <p>Accepts a string as parameter containing the *raw* post data.</p>
528 <p>Returns TRUE on success, or FALSE on failure.</p>
529 <h3 id="HttpRequest_addRawPostData">bool HttpRequest::addRawPostData(string raw_post_data)</h3>
530 <p>Add raw post data, leaving previously set raw post data unchanged.<br />
531 Affects only POST and custom requests.</p>
532 <p>Expects a string as parameter containing the raw post data to concatenate.</p>
533 <p>Returns TRUE on success, or FALSE on failure.</p>
534 <h3 id="HttpRequest_getRawPostData">string HttpRequest::getRawPostData()</h3>
535 <p>Get previously set raw post data.</p>
536 <p>Returns a string containing the currently set raw post data.</p>
537 <h3 id="HttpRequest_addPostFile">bool HttpRequest::addPostFile(string name, string file[, string content_type = "application/x-octetstream"])</h3>
538 <p>Add a file to the POST request, leaving prefiously set files unchanged.<br />
539 Affects only POST and custom requests. Cannot be used with raw post data.</p>
540 <p>Expects a string parameter containing the form element name, and a string<br />
541 paremeter containing the path to the file which should be uploaded.<br />
542 Additionally accepts an optional string parameter which chould contain<br />
543 the content type of the file.</p>
544 <p>Returns TRUE on success, or FALSE if the content type seems not to contain a <br />
545 primary and a secondary content type part.</p>
546 <h3 id="HttpRequest_setPostFiles">bool HttpRequest::setPostFiles([array post_files])</h3>
547 <p>Set files to post, overwriting previously set post files.<br />
548 Affects only POST and requests. Cannot be used with raw post data.</p>
549 <p>Accepts an array containing the files to post. Each entry should be an<br />
550 associative array with "name", "file" and "type" keys. If the parameter<br />
551 is empty or omitted the post files will be unset.</p>
552 <p>Returns TRUE on success, or FALSE on failure.</p>
553 <h3 id="HttpRequest_getPostFiles">array HttpRequest::getPostFiles()</h3>
554 <p>Get all previously added POST files.</p>
555 <p>Returns an array containing currently set post files.</p>
556 <h3 id="HttpRequest_setPutFile">bool HttpRequest::setPutFile([string file])</h3>
557 <p>Set file to put. Affects only PUT requests.</p>
558 <p>Accepts a string as parameter referencing the path to file.<br />
559 If the parameter is empty or omitted the put file will be unset.</p>
560 <p>Returns TRUE on success, or FALSE on failure.</p>
561 <h3 id="HttpRequest_getPutFile">string HttpRequest::getPutFile()</h3>
562 <p>Get previously set put file.</p>
563 <p>Returns a string containing the path to the currently set put file.</p>
564 <h3 id="HttpRequest_getResponseData">array HttpRequest::getResponseData()</h3>
565 <p>Get all response data after the request has been sent.</p>
566 <p>Returns an associative array with the key "headers" containing an associative<br />
567 array holding all response headers, as well as the ley "body" containing a<br />
568 string with the response body. </p>
569 <p>If redirects were allowed and several responses were received, the data <br />
570 references the last received response.</p>
571 <h3 id="HttpRequest_getResponseHeader">mixed HttpRequest::getResponseHeader([string name])</h3>
572 <p>Get response header(s) after the request has been sent.</p>
573 <p>Accepts an string as optional parameter specifying a certain header to read.<br />
574 If the parameter is empty or omitted all response headers will be returned.</p>
575 <p>Returns either a string with the value of the header matching name if requested, <br />
576 FALSE on failure, or an associative array containing all reponse headers.</p>
577 <p>If redirects were allowed and several responses were received, the data <br />
578 references the last received response.</p>
579 <h3 id="HttpRequest_getResponseCookie">array HttpRequest::getResponseCookie([string name])</h3>
580 <p>Get response cookie(s) after the request has been sent.</p>
581 <p>Accepts a string as optional parameter specifying the name of the cookie to read.<br />
582 If the parameter is empty or omitted, an associative array with all received<br />
583 cookies will be returned.</p>
584 <p>Returns either an associative array with the cookie's name, value and any<br />
585 additional params of the cookie matching name if requested, FALSE on failure,<br />
586 or an array containing all received cookies as arrays.</p>
587 <p>If redirects were allowed and several responses were received, the data <br />
588 references the last received response.</p>
589 <h3 id="HttpRequest_getResponseBody">string HttpRequest::getResponseBody()</h3>
590 <p>Get the response body after the request has been sent.</p>
591 <p>Returns a string containing the response body.</p>
592 <p>If redirects were allowed and several responses were received, the data <br />
593 references the last received response.</p>
594 <h3 id="HttpRequest_getResponseCode">int HttpRequest::getResponseCode()</h3>
595 <p>Get the response code after the request has been sent.</p>
596 <p>Returns an int representing the response code.</p>
597 <p>If redirects were allowed and several responses were received, the data <br />
598 references the last received response.</p>
599 <h3 id="HttpRequest_getResponseInfo">mixed HttpRequest::getResponseInfo([string name])</h3>
600 <p>Get response info after the request has been sent.<br />
601 See http_get() for a full list of returned info.</p>
602 <p>Accepts a string as optional parameter specifying the info to read.<br />
603 If the parameter is empty or omitted, an associative array containing<br />
604 all available info will be returned.</p>
605 <p>Returns either a scalar containing the value of the info matching name if<br />
606 requested, FALSE on failure, or an associative array containing all<br />
607 available info.</p>
608 <p>If redirects were allowed and several responses were received, the data <br />
609 references the last received response.</p>
610 <h3 id="HttpRequest_getResponseMessage">HttpMessage HttpRequest::getResponseMessage()</h3>
611 <p>Get the full response as HttpMessage object after the request has been sent.</p>
612 <p>Returns an HttpMessage object of the response.</p>
613 <p>If redirects were allowed and several responses were received, the data <br />
614 references the last received response. Use HttpMessage::getParentMessage()<br />
615 to access the data of previously received responses whithin this request<br />
616 cycle.</p>
617 <p>Throws HttpException.</p>
618 <h3 id="HttpRequest_getRequestMessage">HttpMessage HttpRequest::getRequestMessage()</h3>
619 <p>Get sent HTTP message.</p>
620 <p>Returns an HttpMessage object representing the sent request.</p>
621 <p>If redirects were allowed and several responses were received, the data <br />
622 references the last received response. Use HttpMessage::getParentMessage()<br />
623 to access the data of previously sent requests whithin this request<br />
624 cycle.</p>
625 <h3 id="HttpRequest_getHistory">HttpMessage HttpRequest::getHistory()</h3>
626 <p>Get all sent requests and received responses as an HttpMessage object.</p>
627 <p>If you don't want to record history at all, set the instance variable<br />
628 HttpRequest::$recoedHistory to FALSE. </p>
629 <p>Returns an HttpMessage object representing the complete request/response<br />
630 history.</p>
631 <p>The object references the last received response, use HttpMessage::getParentMessage() <br />
632 to access the data of previously sent requests and received responses.</p>
633 <p>Throws HttpMalformedHeaderException.</p>
634 <h3 id="HttpRequest_clearHistory">void HttpRequest::clearHistory()</h3>
635 <p>Clear the history.</p>
636 <h3 id="HttpRequest_send">HttpMessage HttpRequest::send()</h3>
637 <p>Send the HTTP request.</p>
638 <p>Returns the received response as HttpMessage object.</p>
639 <p>Throws HttpRuntimeException, HttpRequestException, <br />
640 HttpMalformedHeaderException, HttpEncodingException.</p>
641 <p>GET example:</p><pre><blockquote><code><span style="color: #000000"><br />
642 <span style="color: #0000BB">&lt;?php<br />$r&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">HttpRequest</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://example.com/feed.rss'</span><span style="color: #007700">,&nbsp;</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'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</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'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">));<br />try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</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;if&nbsp;(</span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getResponseCode</span><span style="color: #007700">()&nbsp;==&nbsp;</span><span style="color: #0000BB">200</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&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">,&nbsp;</span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getResponseBody</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;}<br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">HttpException&nbsp;$ex</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$ex</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span><br />
643 </span></code></blockquote></p>
644 <p></pre></p>
645 <p>POST example:</p><pre><blockquote><code><span style="color: #000000"><br />
646 <span style="color: #0000BB">&lt;?php<br />$r&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">HttpRequest</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://example.com/form.php'</span><span style="color: #007700">,&nbsp;</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'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">'lang'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</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">addPostFields</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'user'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'mike'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'pass'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</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">,&nbsp;</span><span style="color: #DD0000">'profile.jpg'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'image/jpeg'</span><span style="color: #007700">);<br />try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">send</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">getBody</span><span style="color: #007700">();<br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">HttpException&nbsp;$ex</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$ex</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span><br />
647 </span></code></blockquote></p>
648 <p></pre></p>
649 <hr noshade>
650 <h1>http_requestpool_object.c</h1>
651 <h2 id="HttpRequestPool" class="o">HttpRequestPool</h2>
652 <h3 id="HttpRequestPool___construct">void HttpRequestPool::__construct([HttpRequest request[, ...]])</h3>
653 <p>Instantiate a new HttpRequestPool object. An HttpRequestPool is<br />
654 able to send several HttpRequests in parallel.</p>
655 <p>WARNING: Don't attach/detach HttpRequest objects to the HttpRequestPool<br />
656 object while you're using the implemented Interator interface. </p>
657 <p>Accepts virtual infinite optional parameters each referencing an<br />
658 HttpRequest object.</p>
659 <p>Throws HttpRequestException, HttpRequestPoolException, HttpInvalidParamException.</p>
660 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
661 <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$pool&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">HttpRequestPool</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new&nbsp;</span><span style="color: #0000BB">HttpRequest</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://www.google.com/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">HttpRequest</span><span style="color: #007700">::</span><span style="color: #0000BB">METH_HEAD</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new&nbsp;</span><span style="color: #0000BB">HttpRequest</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://www.php.net/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">HttpRequest</span><span style="color: #007700">::</span><span style="color: #0000BB">METH_HEAD</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">send</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach(</span><span style="color: #0000BB">$pool&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$request</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%s&nbsp;is&nbsp;%s&nbsp;(%d)\n"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$request</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getUrl</span><span style="color: #007700">(),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$request</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getResponseCode</span><span style="color: #007700">()&nbsp;?&nbsp;</span><span style="color: #DD0000">'alive'&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #DD0000">'not&nbsp;alive'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$request</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getResponseCode</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">HttpException&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span><br />
662 </span></code></blockquote></p>
663 <p></pre></p>
664 <h3 id="HttpRequestPool___destruct">void HttpRequestPool::__destruct()</h3>
665 <p>Clean up HttpRequestPool object.</p>
666 <h3 id="HttpRequestPool_reset">void HttpRequestPool::reset()</h3>
667 <p>Detach all attached HttpRequest objects.</p>
668 <h3 id="HttpRequestPool_attach">bool HttpRequestPool::attach(HttpRequest request)</h3>
669 <p>Attach an HttpRequest object to this HttpRequestPool.<br />
670 WARNING: set all options prior attaching!</p>
671 <p>Expects the parameter to be an HttpRequest object not alread attached to<br />
672 antother HttpRequestPool object.</p>
673 <p>Returns TRUE on success, or FALSE on failure.</p>
674 <p>Throws HttpInvalidParamException, HttpRequestException, <br />
675 HttpRequestPoolException, HttpEncodingException.</p>
676 <h3 id="HttpRequestPool_detach">bool HttpRequestPool::detach(HttpRequest request)</h3>
677 <p>Detach an HttpRequest object from this HttpRequestPool.</p>
678 <p>Expects the parameter to be an HttpRequest object attached to this<br />
679 HttpRequestPool object.</p>
680 <p>Returns TRUE on success, or FALSE on failure.</p>
681 <p>Throws HttpInvalidParamException, HttpRequestPoolException.</p>
682 <h3 id="HttpRequestPool_send">bool HttpRequestPool::send()</h3>
683 <p>Send all attached HttpRequest objects in parallel.</p>
684 <p>Returns TRUE on success, or FALSE on failure.</p>
685 <p>Throws HttpSocketException, HttpRequestException, <br />
686 HttpRequestPoolException, HttpMalformedHeaderException.</p>
687 <h3 id="HttpRequestPool_socketPerform">protected bool HttpRequestPool::socketPerform()</h3>
688 <p>Returns TRUE until each request has finished its transaction.</p>
689 <p>Usage:</p><pre><blockquote><code><span style="color: #000000"><br />
690 <span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">while&nbsp;(</span><span style="color: #0000BB">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">socketPerform</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">do_something_else</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #0000BB">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">socketSelect</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">'Socket&nbsp;error'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span><br />
691 </span></code></blockquote></p>
692 <p></pre></p>
693 <h3 id="HttpRequestPool_socketSelect">protected bool HttpRequestPool::socketSelect()</h3>
694 <p>See HttpRequestPool::socketPerform().</p>
695 <p>Returns TRUE on success, or FALSE on failure.</p>
696 <h3 id="HttpRequestPool_valid">bool HttpRequestPool::valid()</h3>
697 <p>Implements Iterator::valid().</p>
698 <h3 id="HttpRequestPool_current">HttpRequest HttpRequestPool::current()</h3>
699 <p>Implements Iterator::current().</p>
700 <h3 id="HttpRequestPool_key">int HttpRequestPool::key()</h3>
701 <p>Implements Iterator::key().</p>
702 <h3 id="HttpRequestPool_next">void HttpRequestPool::next()</h3>
703 <p>Implements Iterator::next().</p>
704 <h3 id="HttpRequestPool_rewind">void HttpRequestPool::rewind()</h3>
705 <p>Implements Iterator::rewind().</p>
706 <hr noshade>
707 <h1>http_response_object.c</h1>
708 <h3 id="HttpResponse_setHeader">static bool HttpResponse::setHeader(string name, mixed value[, bool replace = true])</h3>
709 <p>Send an HTTP header.</p>
710 <p>Expects a string parameter containing the name of the header and a mixed<br />
711 parameter containing the value of the header, which will be converted to<br />
712 a string. Additionally accepts an optional boolean parameter, which<br />
713 specifies whether an existing header should be replaced. If the second<br />
714 parameter is unset no header with this name will be sent. </p>
715 <p>Returns TRUE on success, or FALSE on failure.</p>
716 <p>Throws HttpHeaderException if http.only_exceptions is TRUE.</p>
717 <h3 id="HttpResponse_getHeader">static mixed HttpResponse::getHeader([string name])</h3>
718 <p>Get header(s) about to be sent.</p>
719 <p>Accepts a string as optional parameter which specifies the name of the<br />
720 header to read. If the parameter is empty or omitted, an associative array<br />
721 with all headers will be returned.</p>
722 <p>Returns either a string containing the value of the header matching name,<br />
723 FALSE on failure, or an associative array with all headers.</p>
724 <h3 id="HttpResponse_setCache">static bool HttpResponse::setCache(bool cache)</h3>
725 <p>Whether it sould be attempted to cache the entitity.<br />
726 This will result in necessary caching headers and checks of clients<br />
727 "If-Modified-Since" and "If-None-Match" headers. If one of those headers<br />
728 matches a "304 Not Modified" status code will be issued.</p>
729 <p>NOTE: If you're using sessions, be shure that you set session.cache_limiter<br />
730 to something more appropriate than "no-cache"!</p>
731 <p>Expects a boolean as parameter specifying whether caching should be attempted.</p>
732 <p>Returns TRUE ons success, or FALSE on failure.</p>
733 <h3 id="HttpResponse_getCache">static bool HttpResponse::getCache()</h3>
734 <p>Get current caching setting.</p>
735 <p>Returns TRUE if caching should be attempted, else FALSE.</p>
736 <h3 id="HttpResponse_setGzip">static bool HttpResponse::setGzip(bool gzip)</h3>
737 <p>Enable on-thy-fly gzipping of the sent entity.</p>
738 <p>Expects a boolean as parameter indicating if GZip compression should be enabled.</p>
739 <p>Returns TRUE on success, or FALSE on failure.</p>
740 <h3 id="HttpResponse_getGzip">static bool HttpResponse::getGzip()</h3>
741 <p>Get current gzipping setting.</p>
742 <p>Returns TRUE if GZip compression is enabled, else FALSE.</p>
743 <h3 id="HttpResponse_setCacheControl">static bool HttpResponse::setCacheControl(string control[, int max_age = 0])</h3>
744 <p>Set a custom cache-control header, usually being "private" or "public";<br />
745 The max_age parameter controls how long the cache entry is valid on the client side.</p>
746 <p>Expects a string parameter containing the primary cache control setting.<br />
747 Addtitionally accepts an int parameter specifying the max-age setting.</p>
748 <p>Returns TRUE on success, or FALSE if control does not match one of<br />
749 "public" , "private" or "no-cache".</p>
750 <p>Throws HttpInvalidParamException if http.only_exceptions is TRUE.</p>
751 <h3 id="HttpResponse_getCacheControl">static string HttpResponse::getCacheControl()</h3>
752 <p>Get current Cache-Control header setting.</p>
753 <p>Returns the current cache control setting as a string like sent in a header.</p>
754 <h3 id="HttpResponse_setContentType">static bool HttpResponse::setContentType(string content_type)</h3>
755 <p>Set the content-type of the sent entity.</p>
756 <p>Expects a string as parameter specifying the content type of the sent entity.</p>
757 <p>Returns TRUE on success, or FALSE if the content type does not seem to<br />
758 contain a primary and secondary content type part.</p>
759 <p>Throws HttpInvalidParamException if http.only_exceptions is TRUE.</p>
760 <h3 id="HttpResponse_getContentType">static string HttpResponse::getContentType()</h3>
761 <p>Get current Content-Type header setting.</p>
762 <p>Returns the currently set content type as string.</p>
763 <h3 id="HttpResponse_guessContentType">static string HttpResponse::guessContentType(string magic_file[, long magic_mode = MAGIC_MIME])</h3>
764 <p>Attempts to guess the content type of supplied payload through libmagic.<br />
765 If the attempt is successful, the guessed content type will automatically<br />
766 be set as response content type. </p>
767 <p>Expects a string parameter specifying the magic.mime database to use.<br />
768 Additionally accepts an optional int parameter, being flags for libmagic.</p>
769 <p>Returns the guessed content type on success, or FALSE on failure.</p>
770 <p>Throws HttpRuntimeException, HttpInvalidParamException <br />
771 if http.only_exceptions is TRUE.</p>
772 <h3 id="HttpResponse_setContentDisposition">static bool HttpResponse::setContentDisposition(string filename[, bool inline = false])</h3>
773 <p>Set the Content-Disposition. The Content-Disposition header is very useful<br />
774 if the data actually sent came from a file or something similar, that should<br />
775 be "saved" by the client/user (i.e. by browsers "Save as..." popup window).</p>
776 <p>Expects a string parameter specifying the file name the "Save as..." dialogue<br />
777 should display. Optionally accepts a bool parameter, which, if set to true<br />
778 and the user agent knows how to handle the content type, will probably not<br />
779 cause the popup window to be shown.</p>
780 <p>Returns TRUE on success or FALSE on failure.</p>
781 <h3 id="HttpResponse_getContentDisposition">static string HttpResponse::getContentDisposition()</h3>
782 <p>Get current Content-Disposition setting.</p>
783 <p>Returns the current content disposition as string like sent in a header.</p>
784 <h3 id="HttpResponse_setETag">static bool HttpResponse::setETag(string etag)</h3>
785 <p>Set a custom ETag. Use this only if you know what you're doing.</p>
786 <p>Expects an unquoted string as parameter containing the ETag.</p>
787 <p>Returns TRUE on success, or FALSE on failure.</p>
788 <h3 id="HttpResponse_getETag">static string HttpResponse::getETag()</h3>
789 <p>Get calculated or previously set custom ETag.</p>
790 <p>Returns the calculated or previously set ETag as unquoted string.</p>
791 <h3 id="HttpResponse_setLastModified">static bool HttpResponse::setLastModified(int timestamp)</h3>
792 <p>Set a custom Last-Modified date.</p>
793 <p>Expects an unix timestamp as parameter representing the last modification<br />
794 time of the sent entity.</p>
795 <p>Returns TRUE on success, or FALSE on failure.</p>
796 <h3 id="HttpResponse_getLastModified">static int HttpResponse::getLastModified()</h3>
797 <p>Get calculated or previously set custom Last-Modified date.</p>
798 <p>Returns the calculated or previously set unix timestamp.</p>
799 <h3 id="HttpResponse_setThrottleDelay">static bool HttpResponse::setThrottleDelay(double seconds)</h3>
800 <p>Sets the throttle delay for use with HttpResponse::setBufferSize().</p>
801 <p>Provides a basic throttling mechanism, which will yield the current process<br />
802 resp. thread until the entity has been completely sent, though.</p>
803 <p>Note: This doesn't really work with the FastCGI SAPI.</p>
804 <p>Expects a double parameter specifying the seconds too sleep() after<br />
805 each chunk sent.</p>
806 <p>Returns TRUE on success, or FALSE on failure.</p>
807 <h3 id="HttpResponse_getThrottleDelay">static double HttpResponse::getThrottleDelay()</h3>
808 <p>Get the current throttle delay.</p>
809 <p>Returns a double representing the throttle delay in seconds.</p>
810 <h3 id="HttpResponse_setBufferSize">static bool HttpResponse::setBufferSize(int bytes)</h3>
811 <p>Sets the send buffer size for use with HttpResponse::setThrottleDelay().</p>
812 <p>Provides a basic throttling mechanism, which will yield the current process<br />
813 resp. thread until the entity has been completely sent, though.</p>
814 <p>Note: This doesn't really work with the FastCGI SAPI.</p>
815 <p>Expects an int parameter representing the chunk size in bytes.</p>
816 <p>Returns TRUE on success, or FALSE on failure.</p>
817 <h3 id="HttpResponse_getBufferSize">static int HttpResponse::getBufferSize()</h3>
818 <p>Get current buffer size.</p>
819 <p>Returns an int representing the current buffer size in bytes.</p>
820 <h3 id="HttpResponse_setData">static bool HttpResponse::setData(mixed data)</h3>
821 <p>Set the data to be sent.</p>
822 <p>Expects one parameter, which will be converted to a string and contains <br />
823 the data to send.</p>
824 <p>Returns TRUE on success, or FALSE on failure.</p>
825 <h3 id="HttpResponse_getData">static string HttpResponse::getData()</h3>
826 <p>Get the previously set data to be sent.</p>
827 <p>Returns a string containing the previously set data to send.</p>
828 <h3 id="HttpResponse_setStream">static bool HttpResponse::setStream(resource stream)</h3>
829 <p>Set the resource to be sent.</p>
830 <p>Expects a resource parameter referencing an already opened stream from<br />
831 which the data to send will be read.</p>
832 <p>Returns TRUE on success, or FALSE on failure.</p>
833 <h3 id="HttpResponse_getStream">static resource HttpResponse::getStream()</h3>
834 <p>Get the previously set resource to be sent.</p>
835 <p>Returns the previously set resource.</p>
836 <h3 id="HttpResponse_setFile">static bool HttpResponse::setFile(string file)</h3>
837 <p>Set the file to be sent.</p>
838 <p>Expects a string as parameter, specifying the path to the file to send.</p>
839 <p>Returns TRUE on success, or FALSE on failure.</p>
840 <h3 id="HttpResponse_getFile">static string HttpResponse::getFile()</h3>
841 <p>Get the previously set file to be sent.</p>
842 <p>Returns the previously set path to the file to send as string.</p>
843 <h3 id="HttpResponse_send">static bool HttpResponse::send([bool clean_ob = true])</h3>
844 <p>Finally send the entity.</p>
845 <p>Accepts an optional boolean parameter, specifying wheter the ouput<br />
846 buffers should be discarded prior sending. A successful caching attempt<br />
847 will cause a script termination, and write a log entry if the INI setting<br />
848 http.cache_log is set.</p>
849 <p>Returns TRUE on success, or FALSE on failure.</p>
850 <p>Throws HttpHeaderException, HttpResponseException if http.onyl_excpetions is TRUE.</p>
851 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
852 <span style="color: #0000BB">&lt;?php<br />HttpResponse</span><span style="color: #007700">::</span><span style="color: #0000BB">setCache</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">HttpResponse</span><span style="color: #007700">::</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">HttpResponse</span><span style="color: #007700">::</span><span style="color: #0000BB">setContentDisposition</span><span style="color: #007700">(</span><span style="color: #DD0000">"$user.pdf"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">HttpResponse</span><span style="color: #007700">::</span><span style="color: #0000BB">setFile</span><span style="color: #007700">(</span><span style="color: #DD0000">'sheet.pdf'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">HttpResponse</span><span style="color: #007700">::</span><span style="color: #0000BB">send</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span><br />
853 </span></code></blockquote></p>
854 <p></pre></p>
855 <h3 id="HttpResponse_capture">static void HttpResponse::capture()</h3>
856 <p>Capture script output.</p>
857 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
858 <span style="color: #0000BB">&lt;?php<br />HttpResponse</span><span style="color: #007700">::</span><span style="color: #0000BB">setCache</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">HttpResponse</span><span style="color: #007700">::</span><span style="color: #0000BB">capture</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//&nbsp;script&nbsp;follows<br /></span><span style="color: #0000BB">?&gt;</span><br />
859 </span></code></blockquote></p>
860 <p></pre></p>
861 <hr noshade>
862 <p><b>Generated at: Wed, 05 Oct 2005 14:35:52 +0000</b></p>
863 </body>
864 </html>
865