- export http_parse_cookie()
[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 .toc {
47 position: absolute;
48 top: 10px;
49 right: 10px;
50 width: 300px;
51 height: 95%;
52 overflow: scroll;
53 font-size: .9em;
54 }
55 body>div.toc {
56 position: fixed;
57 }
58 .toc ul {
59 padding-left: 15px;
60 margin-left: 0;
61 }
62 .toc li {
63 padding: 0;
64 margin: 0;
65 }
66 </style>
67 </head>
68 <body><h1 id="http_functions.c">http_functions.c</h1>
69 <h2 id="http_date">string http_date([int timestamp])</h2>
70 <p>Compose a valid HTTP date regarding RFC 822/1123<br />
71 looking like: "Wed, 22 Dec 2004 11:34:47 GMT"</p>
72 <p>Takes an optional unix timestamp as parameter.<br />
73 <br />
74 Returns the HTTP date as string.</p>
75 <h2 id="http_build_uri">string http_build_uri(string url[, string proto[, string host[, int port]]])</h2>
76 <p>Build a complete URI according to the supplied parameters.</p>
77 <p>If the url is already abolute but a different proto was supplied,<br />
78 only the proto part of the URI will be updated. If url has no<br />
79 path specified, the path of the current REQUEST_URI will be taken.<br />
80 The host will be taken either from the Host HTTP header of the client<br />
81 the SERVER_NAME or just localhost if prior are not available.<br />
82 If a port is pecified in either the url or as sperate parameter,<br />
83 it will be added if it differs from te default port for HTTP(S).</p>
84 <p>Returns the absolute URI as string on success or false on failure.</p>
85 <p>Examples:</p><pre><blockquote><code><span style="color: #000000"><br />
86 <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 />
87 </span></code></blockquote></p>
88 <p></pre></p>
89 <h2 id="http_negotiate_language">string http_negotiate_language(array supported[, array &result])</h2>
90 <p>This function negotiates the clients preferred language based on its<br />
91 Accept-Language HTTP header. The qualifier is recognized and languages <br />
92 without qualifier are rated highest. The qualifier will be decreased by<br />
93 10% for partial matches (i.e. matching primary language).</p>
94 <p>Expects an array as parameter cotaining the supported languages as values.<br />
95 If the optional second parameter is supplied, it will be filled with an<br />
96 array containing the negotiation results.</p>
97 <p>Returns the negotiated language or the default language (i.e. first array entry) <br />
98 if none match.</p>
99 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
100 <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 />
101 </span></code></blockquote></p>
102 <p></pre></p>
103 <h2 id="http_negotiate_charset">string http_negotiate_charset(array supported[, array &result])</h2>
104 <p>This function negotiates the clients preferred charset based on its<br />
105 Accept-Charset HTTP header. The qualifier is recognized and charsets <br />
106 without qualifier are rated highest.</p>
107 <p>Expects an array as parameter cotaining the supported charsets as values.<br />
108 If the optional second parameter is supplied, it will be filled with an<br />
109 array containing the negotiation results.</p>
110 <p>Returns the negotiated charset or the default charset (i.e. first array entry) <br />
111 if none match.</p>
112 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
113 <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 />
114 </span></code></blockquote></p>
115 <p></pre></p>
116 <h2 id="http_negotiate_content_type">string http_negotiate_ctype(array supported[, array &result])</h2>
117 <p>This function negotiates the clients preferred content type based on its<br />
118 Accept HTTP header. The qualifier is recognized and content types <br />
119 without qualifier are rated highest.</p>
120 <p>Expects an array as parameter cotaining the supported content types as values.<br />
121 If the optional second parameter is supplied, it will be filled with an<br />
122 array containing the negotiation results.</p>
123 <p>Returns the negotiated content type or the default content type <br />
124 (i.e. first array entry) if none match.</p>
125 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
126 <span style="color: #0000BB">&lt;?php<br />$ctypes&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'application/xhtml+xml'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'text/html'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">http_send_content_type</span><span style="color: #007700">(</span><span style="color: #0000BB">http_negotiate_content_type</span><span style="color: #007700">(</span><span style="color: #0000BB">$ctypes</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span><br />
127 </span></code></blockquote></p>
128 <p></pre></p>
129 <h2 id="http_send_status">bool http_send_status(int status)</h2>
130 <p>Send HTTP status code.</p>
131 <p>Expects an HTTP status code as parameter.</p>
132 <p>Returns TRUE on success or FALSE on failure.</p>
133 <h2 id="http_send_last_modified">bool http_send_last_modified([int timestamp])</h2>
134 <p>Send a "Last-Modified" header with a valid HTTP date.</p>
135 <p>Accepts a unix timestamp, converts it to a valid HTTP date and<br />
136 sends it as "Last-Modified" HTTP header. If timestamp is<br />
137 omitted, the current time will be sent.</p>
138 <p>Returns TRUE on success or FALSE on failure.</p>
139 <h2 id="http_send_content_type">bool http_send_content_type([string content_type = 'application/x-octetstream'])</h2>
140 <p>Send the Content-Type of the sent entity. This is particularly important<br />
141 if you use the http_send() API.</p>
142 <p>Accepts an optional string parameter containing the desired content type <br />
143 (primary/secondary).</p>
144 <p>Returns TRUE on success or FALSE on failure.</p>
145 <h2 id="http_send_content_disposition">bool http_send_content_disposition(string filename[, bool inline = false])</h2>
146 <p>Send the Content-Disposition. The Content-Disposition header is very useful<br />
147 if the data actually sent came from a file or something similar, that should<br />
148 be "saved" by the client/user (i.e. by browsers "Save as..." popup window).</p>
149 <p>Expects a string parameter specifying the file name the "Save as..." dialogue<br />
150 should display. Optionally accepts a bool parameter, which, if set to true<br />
151 and the user agent knows how to handle the content type, will probably not<br />
152 cause the popup window to be shown.</p>
153 <p>Returns TRUE on success or FALSE on failure.</p>
154 <h2 id="http_match_modified">bool http_match_modified([int timestamp[, bool for_range = false]])</h2>
155 <p>Matches the given unix timestamp against the clients "If-Modified-Since" <br />
156 resp. "If-Unmodified-Since" HTTP headers.</p>
157 <p>Accepts a unix timestamp which should be matched. Optionally accepts an<br />
158 additional bool parameter, which if set to true will check the header <br />
159 usually used to validate HTTP ranges. If timestamp is omitted, the<br />
160 current time will be used.</p>
161 <p>Returns TRUE if timestamp represents an earlier date than the header,<br />
162 else FALSE.</p>
163 <h2 id="http_match_etag">bool http_match_etag(string etag[, bool for_range = false])</h2>
164 <p>Matches the given ETag against the clients "If-Match" resp. <br />
165 "If-None-Match" HTTP headers.</p>
166 <p>Expects a string parameter containing the ETag to compare. Optionally<br />
167 accepts a bool parameter, which, if set to true, will check the header<br />
168 usually used to validate HTTP ranges.</p>
169 <p>Retuns TRUE if ETag matches or the header contained the asterisk ("*"),<br />
170 else FALSE.</p>
171 <h2 id="http_cache_last_modified">bool http_cache_last_modified([int timestamp_or_expires]])</h2>
172 <p>Attempts to cache the sent entity by its last modification date.</p>
173 <p>Accepts a unix timestamp as parameter which is handled as follows:</p>
174 <p>If timestamp_or_expires is greater than 0, it is handled as timestamp<br />
175 and will be sent as date of last modification. If it is 0 or omitted,<br />
176 the current time will be sent as Last-Modified date. If it's negative,<br />
177 it is handled as expiration time in seconds, which means that if the<br />
178 requested last modification date is not between the calculated timespan,<br />
179 the Last-Modified header is updated and the actual body will be sent.</p>
180 <p>Returns FALSE on failure, or *exits* with "304 Not Modified" if the entity is cached.</p>
181 <p>A log entry will be written to the cache log if the INI entry<br />
182 http.cache_log is set and the cache attempt was successful.</p>
183 <h2 id="http_cache_etag">bool http_cache_etag([string etag])</h2>
184 <p>Attempts to cache the sent entity by its ETag, either supplied or generated <br />
185 by the hash algorythm specified by the INI setting "http.etag_mode".</p>
186 <p>If the clients "If-None-Match" header matches the supplied/calculated<br />
187 ETag, the body is considered cached on the clients side and<br />
188 a "304 Not Modified" status code is issued.</p>
189 <p>Returns FALSE on failure, or *exits* with "304 Not Modified" if the entity is cached.</p>
190 <p>A log entry is written to the cache log if the INI entry<br />
191 "http.cache_log" is set and the cache attempt was successful.</p>
192 <h2 id="ob_etaghandler">string ob_etaghandler(string data, int mode)</h2>
193 <p>For use with ob_start(). Output buffer handler generating an ETag with<br />
194 the hash algorythm specified with the INI setting "http.etag_mode".</p>
195 <h2 id="http_throttle">void http_throttle(double sec[, int bytes = 40960])</h2>
196 <p>Sets the throttle delay and send buffer size for use with http_send() API.<br />
197 Provides a basic throttling mechanism, which will yield the current process<br />
198 resp. thread until the entity has been completely sent, though.</p>
199 <p>Note: This doesn't really work with the FastCGI SAPI.</p>
200 <p>Expects a double parameter specifying the seconds too sleep() after<br />
201 each chunk sent. Additionally accepts an optional int parameter<br />
202 representing the chunk size in bytes.</p>
203 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
204 <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 />
205 </span></code></blockquote></p>
206 <p></pre></p>
207 <h2 id="http_redirect">void http_redirect([string url[, array params[, bool session = false[, int status = 302]]]])</h2>
208 <p>Redirect to the given url.<br />
209 <br />
210 The supplied url will be expanded with http_build_uri(), the params array will<br />
211 be treated with http_build_query() and the session identification will be appended<br />
212 if session is true.</p>
213 <p>The HTTP response code will be set according to status.<br />
214 You can use one of the following constants for convenience:<br />
215 - HTTP_REDIRECT 302 Found<br />
216 - HTTP_REDIRECT_PERM 301 Moved Permanently<br />
217 - HTTP_REDIRECT_POST 303 See Other<br />
218 - HTTP_REDIRECT_TEMP 307 Temporary Redirect</p>
219 <p>Please see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3<br />
220 for which redirect response code to use in which situation.</p>
221 <p>To be RFC compliant, "Redirecting to <a>URI</a>." will be displayed,<br />
222 if the client doesn't redirect immediatly, and the request method was<br />
223 another one than HEAD.</p>
224 <p>Returns FALSE on failure, or *exits* on success.</p>
225 <p>A log entry will be written to the redirect log, if the INI entry<br />
226 "http.redirect_log" is set and the redirect attempt was successful.</p>
227 <h2 id="http_send_data">bool http_send_data(string data)</h2>
228 <p>Sends raw data with support for (multiple) range requests.</p>
229 <p>Retursn TRUE on success, or FALSE on failure.</p>
230 <h2 id="http_send_file">bool http_send_file(string file)</h2>
231 <p>Sends a file with support for (multiple) range requests.</p>
232 <p>Expects a string parameter referencing the file to send.</p>
233 <p>Returns TRUE on success, or FALSE on failure.</p>
234 <h2 id="http_send_stream">bool http_send_stream(resource stream)</h2>
235 <p>Sends an already opened stream with support for (multiple) range requests.</p>
236 <p>Expects a resource parameter referncing the stream to read from.</p>
237 <p>Returns TRUE on success, or FALSE on failure.</p>
238 <h2 id="http_chunked_decode">string http_chunked_decode(string encoded)</h2>
239 <p>Decodes a string that was HTTP-chunked encoded.</p>
240 <p>Expects a chunked encoded string as parameter.</p>
241 <p>Returns the decoded string on success or FALSE on failure.</p>
242 <h2 id="http_parse_message">object http_parse_message(string message)</h2>
243 <p>Parses (a) http_message(s) into a simple recursive object structure.</p>
244 <p>Expects a string parameter containing a single HTTP message or<br />
245 several consecutive HTTP messages.</p>
246 <p>Returns an hierachical object structure of the parsed messages.</p>
247 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
248 <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 />
249 </span></code></blockquote></p>
250 <p></pre></p>
251 <h2 id="http_parse_headers">array http_parse_headers(string header)</h2>
252 <p>Parses HTTP headers into an associative array.</p>
253 <p>Expects a string parameter containing HTTP headers.</p>
254 <p>Returns an array on success, or FALSE on failure.</p>
255 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
256 <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 /></span><span style="color: #007700">)&nbsp;<br /></span><span style="color: #0000BB">?&gt;</span><br />
257 </span></code></blockquote></p>
258 <p></pre></p>
259 <h2 id="http_parse_cookie">object http_parse_cookie(string cookie)</h2>
260 <p>Parses HTTP cookies like sent in a response into a struct.</p>
261 <p>Expects a string as parameter containing the value of a Set-Cookie response header.</p>
262 <p>Returns an stdClass object with the cookie params as properties on success or FALSE on failure.</p>
263 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
264 <span style="color: #0000BB">&lt;?php<br />print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">http_parse_cookie</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo=bar;&nbsp;path=/"</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">name</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">foo<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">value</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;</span><span style="color: #0000BB">bar<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">path</span><span style="color: #007700">]&nbsp;=&gt;&nbsp;/<br />)<br /></span><span style="color: #0000BB">?&gt;</span><br />
265 </span></code></blockquote></p>
266 <p></pre></p>
267 <h2 id="http_get_request_headers">array http_get_request_headers(void)</h2>
268 <p>Get a list of incoming HTTP headers.</p>
269 <p>Returns an associative array of incoming request headers.</p>
270 <h2 id="http_get_request_body">string http_get_request_body(void)</h2>
271 <p>Get the raw request body (e.g. POST or PUT data).</p>
272 <p>Returns NULL when using the CLI SAPI.</p>
273 <h2 id="http_match_request_header">bool http_match_request_header(string header, string value[, bool match_case = false])</h2>
274 <p>Match an incoming HTTP header.</p>
275 <p>Expects two string parameters representing the header name (case-insensitive)<br />
276 and the header value that should be compared. The case sensitivity of the<br />
277 header value depends on the additional optional bool parameter accepted.</p>
278 <p>Returns TRUE if header value matches, else FALSE.</p>
279 <h2 id="http_get">string http_get(string url[, array options[, array &info]])</h2>
280 <p>Performs an HTTP GET request on the supplied url.</p>
281 <p>The second parameter, if set, is expected to be an associative<br />
282 array where the following keys will be recognized:</p><pre> - redirect: int, whether and how many redirects to follow<br />
283 - unrestrictedauth: bool, whether to continue sending credentials on<br />
284 redirects to a different host<br />
285 - proxyhost: string, proxy host in "host[:port]" format<br />
286 - proxyport: int, use another proxy port as specified in proxyhost<br />
287 - proxyauth: string, proxy credentials in "user:pass" format<br />
288 - proxyauthtype: int, HTTP_AUTH_BASIC and/or HTTP_AUTH_NTLM<br />
289 - httpauth: string, http credentials in "user:pass" format<br />
290 - httpauthtype: int, HTTP_AUTH_BASIC, DIGEST and/or NTLM<br />
291 - compress: bool, whether to allow gzip/deflate content encoding<br />
292 (defaults to true)<br />
293 - port: int, use another port as specified in the url<br />
294 - referer: string, the referer to send<br />
295 - useragent: string, the user agent to send<br />
296 (defaults to PECL::HTTP/version (PHP/version)))<br />
297 - headers: array, list of custom headers as associative array<br />
298 like array("header" => "value")<br />
299 - cookies: array, list of cookies as associative array<br />
300 like array("cookie" => "value")<br />
301 - cookiestore: string, path to a file where cookies are/will be stored<br />
302 - resume: int, byte offset to start the download from;<br />
303 if the server supports ranges<br />
304 - maxfilesize: int, maximum file size that should be downloaded;<br />
305 has no effect, if the size of the requested entity is not known<br />
306 - lastmodified: int, timestamp for If-(Un)Modified-Since header<br />
307 - timeout: int, seconds the request may take<br />
308 - connecttimeout: int, seconds the connect may take<br />
309 - onprogress: mixed, progress callback<br />
310 </pre></p>
311 <p>The optional third parameter will be filled with some additional information<br />
312 in form af an associative array, if supplied, like the following example:</p><pre><blockquote><code><span style="color: #000000"><br />
313 <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 />
314 </span></code></blockquote></p>
315 <p></pre></p>
316 <p>Returns the HTTP response(s) as string on success, or FALSE on failure.</p>
317 <h2 id="http_head">string http_head(string url[, array options[, array &info]])</h2>
318 <p>Performs an HTTP HEAD request on the supplied url.</p>
319 <p>See http_get() for a full list of available parameters and options.</p>
320 <p>Returns the HTTP response as string on success, or FALSE on failure.</p>
321 <h2 id="http_post_data">string http_post_data(string url, string data[, array options[, array &info]])</h2>
322 <p>Performs an HTTP POST requeston the supplied url.</p>
323 <p>Expects a string as second parameter containing the pre-encoded post data.<br />
324 See http_get() for a full list of available parameters and options.<br />
325 <br />
326 Returns the HTTP response(s) as string on success, or FALSE on failure.</p>
327 <h2 id="http_post_fields">string http_post_fields(string url, array data[, array files[, array options[, array &info]]])</h2>
328 <p>Performs an HTTP POST request on the supplied url.</p>
329 <p>Expecrs an associative array as second parameter, which will be<br />
330 www-form-urlencoded. See http_get() for a full list of available options.</p>
331 <p>Returns the HTTP response(s) as string on success, or FALSE on failure.</p>
332 <h2 id="http_put_file">string http_put_file(string url, string file[, array options[, array &info]])</h2>
333 <p>Performs an HTTP PUT request on the supplied url.</p>
334 <p>Expects the second parameter to be a string referncing the file to upload.<br />
335 See http_get() for a full list of available options.</p>
336 <p>Returns the HTTP response(s) as string on success, or FALSE on failure.</p>
337 <h2 id="http_put_stream">string http_put_stream(string url, resource stream[, array options[, array &info]])</h2>
338 <p>Performs an HTTP PUT request on the supplied url.</p>
339 <p>Expects the second parameter to be a resource referencing an already <br />
340 opened stream, from which the data to upload should be read.<br />
341 See http_get() for a full list of available options.</p>
342 <p>Returns the HTTP response(s) as string on success. or FALSE on failure.</p>
343 <h2 id="http_request_method_register">int http_request_method_register(string method)</h2>
344 <p>Register a custom request method.</p>
345 <p>Expects a string parameter containing the request method name to register.</p>
346 <p>Returns the ID of the request method on success, or FALSE on failure.</p>
347 <h2 id="http_request_method_unregister">bool http_request_method_unregister(mixed method)</h2>
348 <p>Unregister a previously registered custom request method.</p>
349 <p>Expects either the request method name or ID.</p>
350 <p>Returns TRUE on success, or FALSE on failure.</p>
351 <h2 id="http_request_method_exists">int http_request_method_exists(mixed method)</h2>
352 <p>Check if a request method is registered (or available by default).</p>
353 <p>Expects either the request method name or ID as parameter.</p>
354 <p>Returns TRUE if the request method is known, else FALSE.</p>
355 <h2 id="http_request_method_name">string http_request_method_name(int method)</h2>
356 <p>Get the literal string representation of a standard or registered request method.</p>
357 <p>Expects the request method ID as parameter.</p>
358 <p>Returns the request method name as string on success, or FALSE on failure.</p>
359 <h2 id="http_build_query">string http_build_query(mixed formdata [, string prefix[, string arg_separator]])</h2>
360 <p>Generates a form-encoded query string from an associative array or object.</p>
361 <h2 id="http_gzencode">string http_gzencode(string data[, int level = -1[, int mtime = 0]])</h2>
362 <p>Compress data with the HTTP compatible GZIP encoding.</p>
363 <p>Expects the first parameter to be a string which contains the data that<br />
364 should be encoded. Additionally accepts an optional in paramter specifying<br />
365 the compression level, where -1 is default, 0 is no compression and 9 is<br />
366 best compression ratio.</p>
367 <p>Returns the encoded string on success, or NULL on failure.</p>
368 <h2 id="http_gzdecode">string http_gzdecode(string data)</h2>
369 <p>Uncompress data compressed with the HTTP compatible GZIP encoding.</p>
370 <p>Expects a string as parameter containing the compressed data.</p>
371 <p>Returns the decoded string on success, or NULL on failure.</p>
372 <h2 id="http_deflate">string http_deflate(string data[, int level = -1[, bool zlib_header = false]])</h2>
373 <p>Compress data with the HTTP compatible DEFLATE encoding.</p>
374 <p>Expects the first parameter to be a string containing the data that should<br />
375 be encoded. Additionally accepts an optional int parameter specifying the<br />
376 compression level, where -1 is default, 0 is no compression and 9 is best<br />
377 compression ratio.</p>
378 <p>Returns the encoded string on success, or NULL on failure.</p>
379 <h2 id="http_inflate">string http_inflate(string data)</h2>
380 <p>Uncompress data compressed with the HTTP compatible DEFLATE encoding.</p>
381 <p>Expects a string as parameter containing the compressed data.</p>
382 <p>Returns the decoded string on success, or NULL on failure.</p>
383 <h2 id="http_support">int http_support([int feature = 0])</h2>
384 <p>Check for feature that require external libraries.</p>
385 <p>Accpepts an optional in parameter specifying which feature to probe for.<br />
386 If the parameter is 0 or omitted, the return value contains a bitmask of <br />
387 all supported features that depend on external libraries.</p>
388 <p>Available features to probe for are:<br />
389 <ul> <br />
390 <li> HTTP_SUPPORT: always set<br />
391 <li> HTTP_SUPPORT_REQUESTS: whether ext/http was linked against libcurl,<br />
392 and HTTP requests can be issued<br />
393 <li> HTTP_SUPPORT_SSLREQUESTS: whether libcurl was linked against openssl,<br />
394 and SSL requests can be issued <br />
395 <li> HTTP_SUPPORT_ENCODINGS: whether ext/http was linked against zlib,<br />
396 and compressed HTTP responses can be decoded<br />
397 <li> HTTP_SUPPORT_MAGICMIME: whether ext/http was linked against libmagic,<br />
398 and the HttpResponse::guessContentType() method is usable<br />
399 </ul></p>
400 <p>Returns int, whether requested feature is supported, or a bitmask with<br />
401 all supported features.</p>
402 <hr noshade>
403 <h1 id="http_message_object.c">http_message_object.c</h1>
404 <h2 id="HttpMessage" class="o">HttpMessage</h2>
405 <h3 id="HttpMessage___construct">void HttpMessage::__construct([string message])</h3>
406 <p>Instantiate a new HttpMessage object.</p>
407 <p>Accepts an optional string parameter containing a single or several <br />
408 consecutive HTTP messages. The constructed object will actually <br />
409 represent the *last* message of the passed string. If there were<br />
410 prior messages, those can be accessed by HttpMessage::getParentMessage().</p>
411 <p>Throws HttpMalformedHeaderException.</p>
412 <h3 id="HttpMessage_fromString">static HttpMessage HttpMessage::fromString(string raw_message)</h3>
413 <p>Create an HttpMessage object from a string. Kind of a static constructor.</p>
414 <p>Expects a string parameter containing a sinlge or several consecutive<br />
415 HTTP messages.</p>
416 <p>Returns an HttpMessage object on success or NULL on failure.</p>
417 <p>Throws HttpMalformedHeadersException.</p>
418 <h3 id="HttpMessage_getBody">string HttpMessage::getBody()</h3>
419 <p>Get the body of the parsed HttpMessage.</p>
420 <p>Returns the message body as string.</p>
421 <h3 id="HttpMessage_setBody">void HttpMessage::setBody(string body)</h3>
422 <p>Set the body of the HttpMessage.<br />
423 NOTE: Don't forget to update any headers accordingly.</p>
424 <p>Expects a string parameter containing the new body of the message.</p>
425 <h3 id="HttpMessage_getHeaders">array HttpMessage::getHeaders()</h3>
426 <p>Get Message Headers.</p>
427 <p>Returns an associative array containing the messages HTTP headers.</p>
428 <h3 id="HttpMessage_setHeaders">void HttpMessage::setHeaders(array headers)</h3>
429 <p>Sets new headers.</p>
430 <p>Expects an associative array as parameter containing the new HTTP headers,<br />
431 which will replace *all* previous HTTP headers of the message.</p>
432 <h3 id="HttpMessage_addHeaders">void HttpMessage::addHeaders(array headers[, bool append = false])</h3>
433 <p>Add headers. If append is true, headers with the same name will be separated, else overwritten.</p>
434 <p>Expects an associative array as parameter containing the additional HTTP headers<br />
435 to add to the messages existing headers. If the optional bool parameter is true,<br />
436 and a header with the same name of one to add exists already, this respective<br />
437 header will be converted to an array containing both header values, otherwise<br />
438 it will be overwritten with the new header value.</p>
439 <h3 id="HttpMessage_getType">int HttpMessage::getType()</h3>
440 <p>Get Message Type. (HTTP_MSG_NONE|HTTP_MSG_REQUEST|HTTP_MSG_RESPONSE)</p>
441 <p>Returns the HttpMessage::TYPE.</p>
442 <h3 id="HttpMessage_setType">void HttpMessage::setType(int type)</h3>
443 <p>Set Message Type. (HTTP_MSG_NONE|HTTP_MSG_REQUEST|HTTP_MSG_RESPONSE)</p>
444 <p>Exptects an int parameter, the HttpMessage::TYPE.</p>
445 <h3 id="HttpMessage_getResponseCode">int HttpMessage::getResponseCode()</h3>
446 <p>Get the Response Code of the Message.</p>
447 <p>Returns the HTTP response code if the message is of type <br />
448 HttpMessage::TYPE_RESPONSE, else FALSE.</p>
449 <h3 id="HttpMessage_setResponseCode">bool HttpMessage::setResponseCode(int code)</h3>
450 <p>Set the response code of an HTTP Response Message.</p>
451 <p>Expects an int parameter with the HTTP response code.</p>
452 <p>Returns TRUE on success, or FALSE if the message is not of type<br />
453 HttpMessage::TYPE_RESPONSE or the response code is out of range (100-510).</p>
454 <h3 id="HttpMessage_getRequestMethod">string HttpMessage::getRequestMethod()</h3>
455 <p>Get the Request Method of the Message.</p>
456 <p>Returns the request method name on success, or FALSE if the message is<br />
457 not of type HttpMessage::TYPE_REQUEST.</p>
458 <h3 id="HttpMessage_setRequestMethod">bool HttpMessage::setRequestMethod(string method)</h3>
459 <p>Set the Request Method of the HTTP Message.</p>
460 <p>Expects a string parameter containing the request method name.</p>
461 <p>Returns TRUE on success, or FALSE if the message is not of type<br />
462 HttpMessage::TYPE_REQUEST or an invalid request method was supplied.</p>
463 <h3 id="HttpMessage_getRequestUri">string HttpMessage::getRequestUri()</h3>
464 <p>Get the Request URI of the Message.</p>
465 <p>Returns the request uri as string on success, or FALSE if the message<br />
466 is not of type HttpMessage::TYPE_REQUEST.</p>
467 <h3 id="HttpMessage_setRequestUri">bool HttpMessage::setRequestUri(string URI)</h3>
468 <p>Set the Request URI of the HTTP Message.</p>
469 <p>Expects a string parameters containing the request uri.</p>
470 <p>Returns TRUE on success, or FALSE if the message is not of type<br />
471 HttpMessage::TYPE_REQUEST or supplied URI was empty.</p>
472 <h3 id="HttpMessage_getHttpVersion">string HttpMessage::getHttpVersion()</h3>
473 <p>Get the HTTP Protocol Version of the Message.</p>
474 <p>Returns the HTTP protocol version as string.</p>
475 <h3 id="HttpMessage_setHttpVersion">bool HttpMessage::setHttpVersion(string version)</h3>
476 <p>Set the HTTP Protocol version of the Message.</p>
477 <p>Expects a string parameter containing the HTTP protocol version.</p>
478 <p>Returns TRUE on success, or FALSE if supplied version is out of range (1.0/1.1).</p>
479 <h3 id="HttpMessage_getParentMessage">HttpMessage HttpMessage::getParentMessage()</h3>
480 <p>Get parent Message.</p>
481 <p>Returns the parent HttpMessage on success, or NULL if there's none.</p>
482 <h3 id="HttpMessage_send">bool HttpMessage::send()</h3>
483 <p>Send the Message according to its type as Response or Request.<br />
484 This provides limited functionality compared to HttpRequest and HttpResponse.</p>
485 <p>Returns TRUE on success, or FALSE on failure.</p>
486 <h3 id="HttpMessage_toString">string HttpMessage::toString([bool include_parent = false])</h3>
487 <p>Get the string representation of the Message.</p>
488 <p>Accepts a bool parameter which specifies whether the returned string<br />
489 should also contain any parent messages.</p>
490 <p>Returns the full message as string.</p>
491 <h3 id="HttpMessage_count">int HttpMessage::count()</h3>
492 <p>Implements Countable.</p>
493 <p>Returns the number of parent messages + 1.</p>
494 <h3 id="HttpMessage_serialize">string HttpMessage::serialize()</h3>
495 <p>Implements Serializable.</p>
496 <p>Returns the serialized representation of the HttpMessage.</p>
497 <h3 id="HttpMessage_unserialize">void HttpMessage::unserialize(string serialized)</h3>
498 <p>Implements Serializable.</p>
499 <p>Re-constructs the HttpMessage based upon the serialized string.</p>
500 <hr noshade>
501 <h1 id="http_request_object.c">http_request_object.c</h1>
502 <h2 id="HttpRequest" class="o">HttpRequest</h2>
503 <h3 id="HttpRequest___construct">void HttpRequest::__construct([string url[, int request_method = HTTP_METH_GET[, array options]]])</h3>
504 <p>Instantiate a new HttpRequest object.</p>
505 <p>Accepts a string as optional parameter containing the target request url.<br />
506 Additianally accepts an optional int parameter specifying the request method<br />
507 to use and an associative array as optional third parameter which will be<br />
508 passed to HttpRequest::setOptions(). </p>
509 <p>Throws HttpException.</p>
510 <h3 id="HttpRequest___destruct">void HttpRequest::__destruct()</h3>
511 <p>Destroys the HttpRequest object.</p>
512 <h3 id="HttpRequest_setOptions">bool HttpRequest::setOptions([array options])</h3>
513 <p>Set the request options to use. See http_get() for a full list of available options.</p>
514 <p>Accepts an array as optional parameters, wich values will overwrite the <br />
515 currently set request options. If the parameter is empty or mitted,<br />
516 the optoions of the HttpRequest object will be reset.</p>
517 <p>Returns TRUE on success, or FALSE on failure.</p>
518 <h3 id="HttpRequest_getOptions">array HttpRequest::getOptions()</h3>
519 <p>Get currently set options.</p>
520 <p>Returns an associative array containing currently set options.</p>
521 <h3 id="HttpRequest_setSslOptions">bool HttpRequest::setSslOptions([array options])</h3>
522 <p>Set SSL options.</p>
523 <p>Accepts an associative array as parameter containing any SSL specific options.<br />
524 If the parameter is empty or omitted, the SSL options will be reset.</p>
525 <p>Returns TRUE on success, or FALSE on failure.</p>
526 <h3 id="HttpRequest_addSslOptions">bool HttpRequest::addSslOptions(array options)</h3>
527 <p>Set additional SSL options.</p>
528 <p>Expects an associative array as parameter containing additional SSL specific options.</p>
529 <p>Returns TRUE on success, or FALSE on failure.</p>
530 <h3 id="HttpRequest_getSslOptions">array HttpRequest::getSslOtpions()</h3>
531 <p>Get previously set SSL options.</p>
532 <p>Returns an associative array containing any previously set SSL options.</p>
533 <h3 id="HttpRequest_addHeaders">bool HttpRequest::addHeaders(array headers)</h3>
534 <p>Add request header name/value pairs.</p>
535 <p>Expects an ssociative array as parameter containing additional header<br />
536 name/value pairs.</p>
537 <p>Returns TRUE on success, or FALSE on failure.</p>
538 <h3 id="HttpRequest_setHeaders">bool HttpRequest::setHeaders([array headers])</h3>
539 <p>Set request header name/value pairs.</p>
540 <p>Accepts an associative array as parameter containing header name/value pairs.<br />
541 If the parameter is empty or omitted, all previously set headers will be unset.</p>
542 <p>Returns TRUE on success, or FALSE on failure.</p>
543 <h3 id="HttpRequest_getHeaders">array HttpRequest::getHeaders()</h3>
544 <p>Get previously set request headers.</p>
545 <p>Returns an associative array containing all currently set headers.</p>
546 <h3 id="HttpRequest_setCookies">bool HttpRequest::setCookies([array cookies])</h3>
547 <p>Set cookies.</p>
548 <p>Accepts an associative array as parameter containing cookie name/value pairs.<br />
549 If the parameter is empty or omitted, all previously set cookies will be unset.</p>
550 <p>Returns TRUE on success, or FALSE on failure.</p>
551 <h3 id="HttpRequest_addCookies">bool HttpRequest::addCookies(array cookies)</h3>
552 <p>Add cookies.</p>
553 <p>Expects an associative array as parameter containing any cookie name/value<br />
554 pairs to add.</p>
555 <p>Returns TRUE on success, or FALSE on failure.</p>
556 <h3 id="HttpRequest_getCookies">array HttpRequest::getCookies()</h3>
557 <p>Get previously set cookies.</p>
558 <p>Returns an associative array containing any previously set cookies.</p>
559 <h3 id="HttpRequest_setUrl">bool HttpRequest::setUrl(string url)</h3>
560 <p>Set the request URL.</p>
561 <p>Expects a string as parameter specifying the request url.</p>
562 <p>Returns TRUE on success, or FALSE on failure.</p>
563 <h3 id="HttpRequest_getUrl">string HttpRequest::getUrl()</h3>
564 <p>Get the previously set request URL.</p>
565 <p>Returns the currently set request url as string.</p>
566 <h3 id="HttpRequest_setMethod">bool HttpRequest::setMethod(int request_method)</h3>
567 <p>Set the request method.</p>
568 <p>Expects an int as parameter specifying the request method to use.<br />
569 In PHP 5.1+ HttpRequest::METH_*, otherwise the HTTP_METH_* constants can be used.</p>
570 <p>Returns TRUE on success, or FALSE on failure.</p>
571 <h3 id="HttpRequest_getMethod">int HttpRequest::getMethod()</h3>
572 <p>Get the previously set request method.</p>
573 <p>Returns the currently set request method.</p>
574 <h3 id="HttpRequest_setContentType">bool HttpRequest::setContentType(string content_type)</h3>
575 <p>Set the content type the post request should have.</p>
576 <p>Expects a string as parameters containing the content type of the request<br />
577 (primary/secondary).</p>
578 <p>Returns TRUE on success, or FALSE if the content type does not seem to<br />
579 contain a primary and a secondary part.</p>
580 <h3 id="HttpRequest_getContentType">string HttpRequest::getContentType()</h3>
581 <p>Get the previously content type.</p>
582 <p>Returns the previously set content type as string.</p>
583 <h3 id="HttpRequest_setQueryData">bool HttpRequest::setQueryData([mixed query_data])</h3>
584 <p>Set the URL query parameters to use, overwriting previously set query parameters.<br />
585 Affects any request types.</p>
586 <p>Accepts a string or associative array parameter containing the pre-encoded <br />
587 query string or to be encoded query fields. If the parameter is empty or<br />
588 omitted, the query data will be unset. </p>
589 <p>Returns TRUE on success, or FALSE on failure.</p>
590 <h3 id="HttpRequest_getQueryData">string HttpRequest::getQueryData()</h3>
591 <p>Get the current query data in form of an urlencoded query string.</p>
592 <p>Returns a string containing the urlencoded query.</p>
593 <h3 id="HttpRequest_addQueryData">bool HttpRequest::addQueryData(array query_params)</h3>
594 <p>Add parameters to the query parameter list, leaving previously set unchanged.<br />
595 Affects any request type.</p>
596 <p>Expects an associative array as parameter containing the query fields to add.</p>
597 <p>Returns TRUE on success, or FALSE on failure.</p>
598 <h3 id="HttpRequest_addPostFields">bool HttpRequest::addPostFields(array post_data)</h3>
599 <p>Adds POST data entries, leaving previously set unchanged, unless a<br />
600 post entry with the same name already exists. <br />
601 Affects only POST and custom requests.</p>
602 <p>Expects an associative array as parameter containing the post fields.</p>
603 <p>Returns TRUE on success, or FALSE on failure.</p>
604 <h3 id="HttpRequest_setPostFields">bool HttpRequest::setPostFields([array post_data])</h3>
605 <p>Set the POST data entries, overwriting previously set POST data.<br />
606 Affects only POST and custom requests.</p>
607 <p>Accepts an associative array as parameter containing the post fields.<br />
608 If the parameter is empty or omitted, the post data will be unset.</p>
609 <p>Returns TRUE on success, or FALSE on failure.</p>
610 <h3 id="HttpRequest_getPostFields">array HttpRequest::getPostFields()</h3>
611 <p>Get previously set POST data.</p>
612 <p>Returns the currently set post fields as associative array.</p>
613 <h3 id="HttpRequest_setRawPostData">bool HttpRequest::setRawPostData([string raw_post_data])</h3>
614 <p>Set raw post data to send, overwriting previously set raw post data. Don't <br />
615 forget to specify a content type. Affects only POST and custom requests.<br />
616 Only either post fields or raw post data can be used for each request.<br />
617 Raw post data has higher precedence and will be used even if post fields<br />
618 are set. </p>
619 <p>Accepts a string as parameter containing the *raw* post data.</p>
620 <p>Returns TRUE on success, or FALSE on failure.</p>
621 <h3 id="HttpRequest_addRawPostData">bool HttpRequest::addRawPostData(string raw_post_data)</h3>
622 <p>Add raw post data, leaving previously set raw post data unchanged.<br />
623 Affects only POST and custom requests.</p>
624 <p>Expects a string as parameter containing the raw post data to concatenate.</p>
625 <p>Returns TRUE on success, or FALSE on failure.</p>
626 <h3 id="HttpRequest_getRawPostData">string HttpRequest::getRawPostData()</h3>
627 <p>Get previously set raw post data.</p>
628 <p>Returns a string containing the currently set raw post data.</p>
629 <h3 id="HttpRequest_addPostFile">bool HttpRequest::addPostFile(string name, string file[, string content_type = "application/x-octetstream"])</h3>
630 <p>Add a file to the POST request, leaving prefiously set files unchanged.<br />
631 Affects only POST and custom requests. Cannot be used with raw post data.</p>
632 <p>Expects a string parameter containing the form element name, and a string<br />
633 paremeter containing the path to the file which should be uploaded.<br />
634 Additionally accepts an optional string parameter which chould contain<br />
635 the content type of the file.</p>
636 <p>Returns TRUE on success, or FALSE if the content type seems not to contain a <br />
637 primary and a secondary content type part.</p>
638 <h3 id="HttpRequest_setPostFiles">bool HttpRequest::setPostFiles([array post_files])</h3>
639 <p>Set files to post, overwriting previously set post files.<br />
640 Affects only POST and requests. Cannot be used with raw post data.</p>
641 <p>Accepts an array containing the files to post. Each entry should be an<br />
642 associative array with "name", "file" and "type" keys. If the parameter<br />
643 is empty or omitted the post files will be unset.</p>
644 <p>Returns TRUE on success, or FALSE on failure.</p>
645 <h3 id="HttpRequest_getPostFiles">array HttpRequest::getPostFiles()</h3>
646 <p>Get all previously added POST files.</p>
647 <p>Returns an array containing currently set post files.</p>
648 <h3 id="HttpRequest_setPutFile">bool HttpRequest::setPutFile([string file])</h3>
649 <p>Set file to put. Affects only PUT requests.</p>
650 <p>Accepts a string as parameter referencing the path to file.<br />
651 If the parameter is empty or omitted the put file will be unset.</p>
652 <p>Returns TRUE on success, or FALSE on failure.</p>
653 <h3 id="HttpRequest_getPutFile">string HttpRequest::getPutFile()</h3>
654 <p>Get previously set put file.</p>
655 <p>Returns a string containing the path to the currently set put file.</p>
656 <h3 id="HttpRequest_getResponseData">array HttpRequest::getResponseData()</h3>
657 <p>Get all response data after the request has been sent.</p>
658 <p>Returns an associative array with the key "headers" containing an associative<br />
659 array holding all response headers, as well as the ley "body" containing a<br />
660 string with the response body. </p>
661 <p>If redirects were allowed and several responses were received, the data <br />
662 references the last received response.</p>
663 <h3 id="HttpRequest_getResponseHeader">mixed HttpRequest::getResponseHeader([string name])</h3>
664 <p>Get response header(s) after the request has been sent.</p>
665 <p>Accepts an string as optional parameter specifying a certain header to read.<br />
666 If the parameter is empty or omitted all response headers will be returned.</p>
667 <p>Returns either a string with the value of the header matching name if requested, <br />
668 FALSE on failure, or an associative array containing all reponse headers.</p>
669 <p>If redirects were allowed and several responses were received, the data <br />
670 references the last received response.</p>
671 <h3 id="HttpRequest_getResponseCookie">array HttpRequest::getResponseCookie([string name])</h3>
672 <p>Get response cookie(s) after the request has been sent.</p>
673 <p>Accepts a string as optional parameter specifying the name of the cookie to read.<br />
674 If the parameter is empty or omitted, an associative array with all received<br />
675 cookies will be returned.</p>
676 <p>Returns either an associative array with the cookie's name, value and any<br />
677 additional params of the cookie matching name if requested, FALSE on failure,<br />
678 or an array containing all received cookies as arrays.</p>
679 <p>If redirects were allowed and several responses were received, the data <br />
680 references the last received response.</p>
681 <h3 id="HttpRequest_getResponseBody">string HttpRequest::getResponseBody()</h3>
682 <p>Get the response body after the request has been sent.</p>
683 <p>Returns a string containing the response body.</p>
684 <p>If redirects were allowed and several responses were received, the data <br />
685 references the last received response.</p>
686 <h3 id="HttpRequest_getResponseCode">int HttpRequest::getResponseCode()</h3>
687 <p>Get the response code after the request has been sent.</p>
688 <p>Returns an int representing the response code.</p>
689 <p>If redirects were allowed and several responses were received, the data <br />
690 references the last received response.</p>
691 <h3 id="HttpRequest_getResponseInfo">mixed HttpRequest::getResponseInfo([string name])</h3>
692 <p>Get response info after the request has been sent.<br />
693 See http_get() for a full list of returned info.</p>
694 <p>Accepts a string as optional parameter specifying the info to read.<br />
695 If the parameter is empty or omitted, an associative array containing<br />
696 all available info will be returned.</p>
697 <p>Returns either a scalar containing the value of the info matching name if<br />
698 requested, FALSE on failure, or an associative array containing all<br />
699 available info.</p>
700 <p>If redirects were allowed and several responses were received, the data <br />
701 references the last received response.</p>
702 <h3 id="HttpRequest_getResponseMessage">HttpMessage HttpRequest::getResponseMessage()</h3>
703 <p>Get the full response as HttpMessage object after the request has been sent.</p>
704 <p>Returns an HttpMessage object of the response.</p>
705 <p>If redirects were allowed and several responses were received, the data <br />
706 references the last received response. Use HttpMessage::getParentMessage()<br />
707 to access the data of previously received responses whithin this request<br />
708 cycle.</p>
709 <p>Throws HttpException.</p>
710 <h3 id="HttpRequest_getRequestMessage">HttpMessage HttpRequest::getRequestMessage()</h3>
711 <p>Get sent HTTP message.</p>
712 <p>Returns an HttpMessage object representing the sent request.</p>
713 <p>If redirects were allowed and several responses were received, the data <br />
714 references the last received response. Use HttpMessage::getParentMessage()<br />
715 to access the data of previously sent requests whithin this request<br />
716 cycle.</p>
717 <p>Note that the internal request message is immutable, that means that the<br />
718 request message received through HttpRequest::getRequestMessage() will<br />
719 always look the same for the same request, regardless of any changes you<br />
720 may have made to the returned object.</p>
721 <p>Throws HttpMalformedHeadersException, HttpEncodingException.</p>
722 <h3 id="HttpRequest_getHistory">HttpMessage HttpRequest::getHistory()</h3>
723 <p>Get all sent requests and received responses as an HttpMessage object.</p>
724 <p>If you don't want to record history at all, set the instance variable<br />
725 HttpRequest::$recoedHistory to FALSE. </p>
726 <p>Returns an HttpMessage object representing the complete request/response<br />
727 history.</p>
728 <p>The object references the last received response, use HttpMessage::getParentMessage() <br />
729 to access the data of previously sent requests and received responses.</p>
730 <p>Note that the internal history is immutable, that means that any changes<br />
731 you make the the message list won't affect a history message list newly <br />
732 created by another call to HttpRequest::getHistory().</p>
733 <p>Throws HttpMalformedHeaderException, HttpEncodingException.</p>
734 <h3 id="HttpRequest_clearHistory">void HttpRequest::clearHistory()</h3>
735 <p>Clear the history.</p>
736 <h3 id="HttpRequest_send">HttpMessage HttpRequest::send()</h3>
737 <p>Send the HTTP request.</p>
738 <p>Returns the received response as HttpMessage object.</p>
739 <p>NOTE: While an exception may be thrown, the transfer could have succeeded <br />
740 at least partially, so you might want to check the return values of various<br />
741 HttpRequest::getResponse*() methods.</p>
742 <p>Throws HttpRuntimeException, HttpRequestException, <br />
743 HttpMalformedHeaderException, HttpEncodingException.</p>
744 <p>GET example:</p><pre><blockquote><code><span style="color: #000000"><br />
745 <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">HttpRequest</span><span style="color: #007700">::</span><span style="color: #0000BB">METH_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 />
746 </span></code></blockquote></p>
747 <p></pre></p>
748 <p>POST example:</p><pre><blockquote><code><span style="color: #000000"><br />
749 <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">HttpRequest</span><span style="color: #007700">::</span><span style="color: #0000BB">METH_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 />
750 </span></code></blockquote></p>
751 <p></pre></p>
752 <hr noshade>
753 <h1 id="http_requestpool_object.c">http_requestpool_object.c</h1>
754 <h2 id="HttpRequestPool" class="o">HttpRequestPool</h2>
755 <h3 id="HttpRequestPool___construct">void HttpRequestPool::__construct([HttpRequest request[, ...]])</h3>
756 <p>Instantiate a new HttpRequestPool object. An HttpRequestPool is<br />
757 able to send several HttpRequests in parallel.</p>
758 <p>WARNING: Don't attach/detach HttpRequest objects to the HttpRequestPool<br />
759 object while you're using the implemented Iterator interface. </p>
760 <p>Accepts virtual infinite optional parameters each referencing an<br />
761 HttpRequest object.</p>
762 <p>Throws HttpRequestPoolException (HttpRequestException, HttpInvalidParamException).</p>
763 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
764 <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 />
765 </span></code></blockquote></p>
766 <p></pre></p>
767 <h3 id="HttpRequestPool___destruct">void HttpRequestPool::__destruct()</h3>
768 <p>Clean up HttpRequestPool object.</p>
769 <h3 id="HttpRequestPool_reset">void HttpRequestPool::reset()</h3>
770 <p>Detach all attached HttpRequest objects.</p>
771 <h3 id="HttpRequestPool_attach">bool HttpRequestPool::attach(HttpRequest request)</h3>
772 <p>Attach an HttpRequest object to this HttpRequestPool.<br />
773 WARNING: set all options prior attaching!</p>
774 <p>Expects the parameter to be an HttpRequest object not alread attached to<br />
775 antother HttpRequestPool object.</p>
776 <p>Returns TRUE on success, or FALSE on failure.</p>
777 <p>Throws HttpInvalidParamException, HttpRequestException, <br />
778 HttpRequestPoolException, HttpEncodingException.</p>
779 <h3 id="HttpRequestPool_detach">bool HttpRequestPool::detach(HttpRequest request)</h3>
780 <p>Detach an HttpRequest object from this HttpRequestPool.</p>
781 <p>Expects the parameter to be an HttpRequest object attached to this<br />
782 HttpRequestPool object.</p>
783 <p>Returns TRUE on success, or FALSE on failure.</p>
784 <p>Throws HttpInvalidParamException, HttpRequestPoolException.</p>
785 <h3 id="HttpRequestPool_send">bool HttpRequestPool::send()</h3>
786 <p>Send all attached HttpRequest objects in parallel.</p>
787 <p>Returns TRUE on success, or FALSE on failure.</p>
788 <p>Throws HttpRequestPoolException (HttpSocketException, HttpRequestException, HttpMalformedHeaderException).</p>
789 <h3 id="HttpRequestPool_socketPerform">protected bool HttpRequestPool::socketPerform()</h3>
790 <p>Returns TRUE until each request has finished its transaction.</p>
791 <p>Usage:</p><pre><blockquote><code><span style="color: #000000"><br />
792 <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">MyPool&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">HttpRequestPool<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">send</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(</span><span style="color: #0000BB">$this</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;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #0000BB">$this</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;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;</span><span style="color: #0000BB">HttpSocketExcpetion</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;final&nbsp;function&nbsp;</span><span style="color: #0000BB">socketPerform</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">parent</span><span style="color: #007700">::</span><span style="color: #0000BB">socketPerform</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getFinishedRequests</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$r</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">detach</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;handle&nbsp;response&nbsp;of&nbsp;finished&nbsp;request<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}&nbsp;<br /></span><span style="color: #0000BB">?&gt;</span><br />
793 </span></code></blockquote></p>
794 <p></pre></p>
795 <h3 id="HttpRequestPool_socketSelect">protected bool HttpRequestPool::socketSelect()</h3>
796 <p>See HttpRequestPool::socketPerform().</p>
797 <p>Returns TRUE on success, or FALSE on failure.</p>
798 <h3 id="HttpRequestPool_valid">bool HttpRequestPool::valid()</h3>
799 <p>Implements Iterator::valid().</p>
800 <h3 id="HttpRequestPool_current">HttpRequest HttpRequestPool::current()</h3>
801 <p>Implements Iterator::current().</p>
802 <h3 id="HttpRequestPool_key">int HttpRequestPool::key()</h3>
803 <p>Implements Iterator::key().</p>
804 <h3 id="HttpRequestPool_next">void HttpRequestPool::next()</h3>
805 <p>Implements Iterator::next().</p>
806 <h3 id="HttpRequestPool_rewind">void HttpRequestPool::rewind()</h3>
807 <p>Implements Iterator::rewind().</p>
808 <h3 id="HttpRequestPool_count">int HttpRequestPool::count()</h3>
809 <p>Implements Countable.</p>
810 <p>Returns the number of attached HttpRequest objects.</p>
811 <h3 id="HttpRequestPool_getAttachedRequests">array HttpRequestPool::getAttachedRequests()</h3>
812 <p>Get attached HttpRequest objects.</p>
813 <p>Returns an array containing all currently attached HttpRequest objects.</p>
814 <h3 id="HttpRequestPool_getFinishedRequests">array HttpRequestPool::getFinishedRequests()</h3>
815 <p>Get attached HttpRequest objects that already have finished their work.</p>
816 <p>Returns an array containing all attached HttpRequest objects that<br />
817 already have finished their work.</p>
818 <hr noshade>
819 <h1 id="http_response_object.c">http_response_object.c</h1>
820 <h3 id="HttpResponse_setHeader">static bool HttpResponse::setHeader(string name, mixed value[, bool replace = true])</h3>
821 <p>Send an HTTP header.</p>
822 <p>Expects a string parameter containing the name of the header and a mixed<br />
823 parameter containing the value of the header, which will be converted to<br />
824 a string. Additionally accepts an optional boolean parameter, which<br />
825 specifies whether an existing header should be replaced. If the second<br />
826 parameter is unset no header with this name will be sent. </p>
827 <p>Returns TRUE on success, or FALSE on failure.</p>
828 <p>Throws HttpHeaderException if http.only_exceptions is TRUE.</p>
829 <h3 id="HttpResponse_getHeader">static mixed HttpResponse::getHeader([string name])</h3>
830 <p>Get header(s) about to be sent.</p>
831 <p>Accepts a string as optional parameter which specifies the name of the<br />
832 header to read. If the parameter is empty or omitted, an associative array<br />
833 with all headers will be returned.</p>
834 <p>Returns either a string containing the value of the header matching name,<br />
835 FALSE on failure, or an associative array with all headers.</p>
836 <h3 id="HttpResponse_setCache">static bool HttpResponse::setCache(bool cache)</h3>
837 <p>Whether it sould be attempted to cache the entitity.<br />
838 This will result in necessary caching headers and checks of clients<br />
839 "If-Modified-Since" and "If-None-Match" headers. If one of those headers<br />
840 matches a "304 Not Modified" status code will be issued.</p>
841 <p>NOTE: If you're using sessions, be shure that you set session.cache_limiter<br />
842 to something more appropriate than "no-cache"!</p>
843 <p>Expects a boolean as parameter specifying whether caching should be attempted.</p>
844 <p>Returns TRUE ons success, or FALSE on failure.</p>
845 <h3 id="HttpResponse_getCache">static bool HttpResponse::getCache()</h3>
846 <p>Get current caching setting.</p>
847 <p>Returns TRUE if caching should be attempted, else FALSE.</p>
848 <h3 id="HttpResponse_setGzip">static bool HttpResponse::setGzip(bool gzip)</h3>
849 <p>Enable on-thy-fly gzipping of the sent entity.</p>
850 <p>Expects a boolean as parameter indicating if GZip compression should be enabled.</p>
851 <p>Returns TRUE on success, or FALSE on failure.</p>
852 <h3 id="HttpResponse_getGzip">static bool HttpResponse::getGzip()</h3>
853 <p>Get current gzipping setting.</p>
854 <p>Returns TRUE if GZip compression is enabled, else FALSE.</p>
855 <h3 id="HttpResponse_setCacheControl">static bool HttpResponse::setCacheControl(string control[, int max_age = 0])</h3>
856 <p>Set a custom cache-control header, usually being "private" or "public";<br />
857 The max_age parameter controls how long the cache entry is valid on the client side.</p>
858 <p>Expects a string parameter containing the primary cache control setting.<br />
859 Addtitionally accepts an int parameter specifying the max-age setting.</p>
860 <p>Returns TRUE on success, or FALSE if control does not match one of<br />
861 "public" , "private" or "no-cache".</p>
862 <p>Throws HttpInvalidParamException if http.only_exceptions is TRUE.</p>
863 <h3 id="HttpResponse_getCacheControl">static string HttpResponse::getCacheControl()</h3>
864 <p>Get current Cache-Control header setting.</p>
865 <p>Returns the current cache control setting as a string like sent in a header.</p>
866 <h3 id="HttpResponse_setContentType">static bool HttpResponse::setContentType(string content_type)</h3>
867 <p>Set the content-type of the sent entity.</p>
868 <p>Expects a string as parameter specifying the content type of the sent entity.</p>
869 <p>Returns TRUE on success, or FALSE if the content type does not seem to<br />
870 contain a primary and secondary content type part.</p>
871 <p>Throws HttpInvalidParamException if http.only_exceptions is TRUE.</p>
872 <h3 id="HttpResponse_getContentType">static string HttpResponse::getContentType()</h3>
873 <p>Get current Content-Type header setting.</p>
874 <p>Returns the currently set content type as string.</p>
875 <h3 id="HttpResponse_guessContentType">static string HttpResponse::guessContentType(string magic_file[, int magic_mode = MAGIC_MIME])</h3>
876 <p>Attempts to guess the content type of supplied payload through libmagic.<br />
877 If the attempt is successful, the guessed content type will automatically<br />
878 be set as response content type. </p>
879 <p>Expects a string parameter specifying the magic.mime database to use.<br />
880 Additionally accepts an optional int parameter, being flags for libmagic.</p>
881 <p>Returns the guessed content type on success, or FALSE on failure.</p>
882 <p>Throws HttpRuntimeException, HttpInvalidParamException <br />
883 if http.only_exceptions is TRUE.</p>
884 <h3 id="HttpResponse_setContentDisposition">static bool HttpResponse::setContentDisposition(string filename[, bool inline = false])</h3>
885 <p>Set the Content-Disposition. The Content-Disposition header is very useful<br />
886 if the data actually sent came from a file or something similar, that should<br />
887 be "saved" by the client/user (i.e. by browsers "Save as..." popup window).</p>
888 <p>Expects a string parameter specifying the file name the "Save as..." dialogue<br />
889 should display. Optionally accepts a bool parameter, which, if set to true<br />
890 and the user agent knows how to handle the content type, will probably not<br />
891 cause the popup window to be shown.</p>
892 <p>Returns TRUE on success or FALSE on failure.</p>
893 <h3 id="HttpResponse_getContentDisposition">static string HttpResponse::getContentDisposition()</h3>
894 <p>Get current Content-Disposition setting.</p>
895 <p>Returns the current content disposition as string like sent in a header.</p>
896 <h3 id="HttpResponse_setETag">static bool HttpResponse::setETag(string etag)</h3>
897 <p>Set a custom ETag. Use this only if you know what you're doing.</p>
898 <p>Expects an unquoted string as parameter containing the ETag.</p>
899 <p>Returns TRUE on success, or FALSE on failure.</p>
900 <h3 id="HttpResponse_getETag">static string HttpResponse::getETag()</h3>
901 <p>Get calculated or previously set custom ETag.</p>
902 <p>Returns the calculated or previously set ETag as unquoted string.</p>
903 <h3 id="HttpResponse_setLastModified">static bool HttpResponse::setLastModified(int timestamp)</h3>
904 <p>Set a custom Last-Modified date.</p>
905 <p>Expects an unix timestamp as parameter representing the last modification<br />
906 time of the sent entity.</p>
907 <p>Returns TRUE on success, or FALSE on failure.</p>
908 <h3 id="HttpResponse_getLastModified">static int HttpResponse::getLastModified()</h3>
909 <p>Get calculated or previously set custom Last-Modified date.</p>
910 <p>Returns the calculated or previously set unix timestamp.</p>
911 <h3 id="HttpResponse_setThrottleDelay">static bool HttpResponse::setThrottleDelay(double seconds)</h3>
912 <p>Sets the throttle delay for use with HttpResponse::setBufferSize().</p>
913 <p>Provides a basic throttling mechanism, which will yield the current process<br />
914 resp. thread until the entity has been completely sent, though.</p>
915 <p>Note: This doesn't really work with the FastCGI SAPI.</p>
916 <p>Expects a double parameter specifying the seconds too sleep() after<br />
917 each chunk sent.</p>
918 <p>Returns TRUE on success, or FALSE on failure.</p>
919 <h3 id="HttpResponse_getThrottleDelay">static double HttpResponse::getThrottleDelay()</h3>
920 <p>Get the current throttle delay.</p>
921 <p>Returns a double representing the throttle delay in seconds.</p>
922 <h3 id="HttpResponse_setBufferSize">static bool HttpResponse::setBufferSize(int bytes)</h3>
923 <p>Sets the send buffer size for use with HttpResponse::setThrottleDelay().</p>
924 <p>Provides a basic throttling mechanism, which will yield the current process<br />
925 resp. thread until the entity has been completely sent, though.</p>
926 <p>Note: This doesn't really work with the FastCGI SAPI.</p>
927 <p>Expects an int parameter representing the chunk size in bytes.</p>
928 <p>Returns TRUE on success, or FALSE on failure.</p>
929 <h3 id="HttpResponse_getBufferSize">static int HttpResponse::getBufferSize()</h3>
930 <p>Get current buffer size.</p>
931 <p>Returns an int representing the current buffer size in bytes.</p>
932 <h3 id="HttpResponse_setData">static bool HttpResponse::setData(mixed data)</h3>
933 <p>Set the data to be sent.</p>
934 <p>Expects one parameter, which will be converted to a string and contains <br />
935 the data to send.</p>
936 <p>Returns TRUE on success, or FALSE on failure.</p>
937 <h3 id="HttpResponse_getData">static string HttpResponse::getData()</h3>
938 <p>Get the previously set data to be sent.</p>
939 <p>Returns a string containing the previously set data to send.</p>
940 <h3 id="HttpResponse_setStream">static bool HttpResponse::setStream(resource stream)</h3>
941 <p>Set the resource to be sent.</p>
942 <p>Expects a resource parameter referencing an already opened stream from<br />
943 which the data to send will be read.</p>
944 <p>Returns TRUE on success, or FALSE on failure.</p>
945 <h3 id="HttpResponse_getStream">static resource HttpResponse::getStream()</h3>
946 <p>Get the previously set resource to be sent.</p>
947 <p>Returns the previously set resource.</p>
948 <h3 id="HttpResponse_setFile">static bool HttpResponse::setFile(string file)</h3>
949 <p>Set the file to be sent.</p>
950 <p>Expects a string as parameter, specifying the path to the file to send.</p>
951 <p>Returns TRUE on success, or FALSE on failure.</p>
952 <h3 id="HttpResponse_getFile">static string HttpResponse::getFile()</h3>
953 <p>Get the previously set file to be sent.</p>
954 <p>Returns the previously set path to the file to send as string.</p>
955 <h3 id="HttpResponse_send">static bool HttpResponse::send([bool clean_ob = true])</h3>
956 <p>Finally send the entity.</p>
957 <p>Accepts an optional boolean parameter, specifying wheter the ouput<br />
958 buffers should be discarded prior sending. A successful caching attempt<br />
959 will cause a script termination, and write a log entry if the INI setting<br />
960 http.cache_log is set.</p>
961 <p>Returns TRUE on success, or FALSE on failure.</p>
962 <p>Throws HttpHeaderException, HttpResponseException if http.onyl_excpetions is TRUE.</p>
963 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
964 <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 />
965 </span></code></blockquote></p>
966 <p></pre></p>
967 <h3 id="HttpResponse_capture">static void HttpResponse::capture()</h3>
968 <p>Capture script output.</p>
969 <p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
970 <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 />
971 </span></code></blockquote></p>
972 <p></pre></p>
973 <hr noshade>
974 <div class="toc"><strong>Table of Contents</strong>
975 <ul>
976 <li><a href="#http_functions.c">http_functions.c
977 <ul>
978 <li><a href="#http_date">http_date</a>
979 </li>
980 <li><a href="#http_build_uri">http_build_uri</a>
981 </li>
982 <li><a href="#http_negotiate_language">http_negotiate_language</a>
983 </li>
984 <li><a href="#http_negotiate_charset">http_negotiate_charset</a>
985 </li>
986 <li><a href="#http_negotiate_content_type">http_negotiate_content_type</a>
987 </li>
988 <li><a href="#http_send_status">http_send_status</a>
989 </li>
990 <li><a href="#http_send_last_modified">http_send_last_modified</a>
991 </li>
992 <li><a href="#http_send_content_type">http_send_content_type</a>
993 </li>
994 <li><a href="#http_send_content_disposition">http_send_content_disposition</a>
995 </li>
996 <li><a href="#http_match_modified">http_match_modified</a>
997 </li>
998 <li><a href="#http_match_etag">http_match_etag</a>
999 </li>
1000 <li><a href="#http_cache_last_modified">http_cache_last_modified</a>
1001 </li>
1002 <li><a href="#http_cache_etag">http_cache_etag</a>
1003 </li>
1004 <li><a href="#ob_etaghandler">ob_etaghandler</a>
1005 </li>
1006 <li><a href="#http_throttle">http_throttle</a>
1007 </li>
1008 <li><a href="#http_redirect">http_redirect</a>
1009 </li>
1010 <li><a href="#http_send_data">http_send_data</a>
1011 </li>
1012 <li><a href="#http_send_file">http_send_file</a>
1013 </li>
1014 <li><a href="#http_send_stream">http_send_stream</a>
1015 </li>
1016 <li><a href="#http_chunked_decode">http_chunked_decode</a>
1017 </li>
1018 <li><a href="#http_parse_message">http_parse_message</a>
1019 </li>
1020 <li><a href="#http_parse_headers">http_parse_headers</a>
1021 </li>
1022 <li><a href="#http_parse_cookie">http_parse_cookie</a>
1023 </li>
1024 <li><a href="#http_get_request_headers">http_get_request_headers</a>
1025 </li>
1026 <li><a href="#http_get_request_body">http_get_request_body</a>
1027 </li>
1028 <li><a href="#http_match_request_header">http_match_request_header</a>
1029 </li>
1030 <li><a href="#http_get">http_get</a>
1031 </li>
1032 <li><a href="#http_head">http_head</a>
1033 </li>
1034 <li><a href="#http_post_data">http_post_data</a>
1035 </li>
1036 <li><a href="#http_post_fields">http_post_fields</a>
1037 </li>
1038 <li><a href="#http_put_file">http_put_file</a>
1039 </li>
1040 <li><a href="#http_put_stream">http_put_stream</a>
1041 </li>
1042 <li><a href="#http_request_method_register">http_request_method_register</a>
1043 </li>
1044 <li><a href="#http_request_method_unregister">http_request_method_unregister</a>
1045 </li>
1046 <li><a href="#http_request_method_exists">http_request_method_exists</a>
1047 </li>
1048 <li><a href="#http_request_method_name">http_request_method_name</a>
1049 </li>
1050 <li><a href="#http_build_query">http_build_query</a>
1051 </li>
1052 <li><a href="#http_gzencode">http_gzencode</a>
1053 </li>
1054 <li><a href="#http_gzdecode">http_gzdecode</a>
1055 </li>
1056 <li><a href="#http_deflate">http_deflate</a>
1057 </li>
1058 <li><a href="#http_inflate">http_inflate</a>
1059 </li>
1060 <li><a href="#http_support">http_support</a>
1061 </li>
1062 </ul>
1063 </li>
1064 <li><a href="#http_message_object.c">http_message_object.c
1065 <ul>
1066 <li><a href="#HttpMessage___construct">HttpMessage::__construct()</a></li>
1067 <li><a href="#HttpMessage_fromString">HttpMessage::fromString()</a></li>
1068 <li><a href="#HttpMessage_getBody">HttpMessage::getBody()</a></li>
1069 <li><a href="#HttpMessage_setBody">HttpMessage::setBody()</a></li>
1070 <li><a href="#HttpMessage_getHeaders">HttpMessage::getHeaders()</a></li>
1071 <li><a href="#HttpMessage_setHeaders">HttpMessage::setHeaders()</a></li>
1072 <li><a href="#HttpMessage_addHeaders">HttpMessage::addHeaders()</a></li>
1073 <li><a href="#HttpMessage_getType">HttpMessage::getType()</a></li>
1074 <li><a href="#HttpMessage_setType">HttpMessage::setType()</a></li>
1075 <li><a href="#HttpMessage_getResponseCode">HttpMessage::getResponseCode()</a></li>
1076 <li><a href="#HttpMessage_setResponseCode">HttpMessage::setResponseCode()</a></li>
1077 <li><a href="#HttpMessage_getRequestMethod">HttpMessage::getRequestMethod()</a></li>
1078 <li><a href="#HttpMessage_setRequestMethod">HttpMessage::setRequestMethod()</a></li>
1079 <li><a href="#HttpMessage_getRequestUri">HttpMessage::getRequestUri()</a></li>
1080 <li><a href="#HttpMessage_setRequestUri">HttpMessage::setRequestUri()</a></li>
1081 <li><a href="#HttpMessage_getHttpVersion">HttpMessage::getHttpVersion()</a></li>
1082 <li><a href="#HttpMessage_setHttpVersion">HttpMessage::setHttpVersion()</a></li>
1083 <li><a href="#HttpMessage_getParentMessage">HttpMessage::getParentMessage()</a></li>
1084 <li><a href="#HttpMessage_send">HttpMessage::send()</a></li>
1085 <li><a href="#HttpMessage_toString">HttpMessage::toString()</a></li>
1086 <li><a href="#HttpMessage_count">HttpMessage::count()</a></li>
1087 <li><a href="#HttpMessage_serialize">HttpMessage::serialize()</a></li>
1088 <li><a href="#HttpMessage_unserialize">HttpMessage::unserialize()</a></li>
1089 </li>
1090 </ul>
1091 </li>
1092 <li><a href="#http_request_object.c">http_request_object.c
1093 <ul>
1094 <li><a href="#HttpRequest___construct">HttpRequest::__construct()</a></li>
1095 <li><a href="#HttpRequest___destruct">HttpRequest::__destruct()</a></li>
1096 <li><a href="#HttpRequest_setOptions">HttpRequest::setOptions()</a></li>
1097 <li><a href="#HttpRequest_getOptions">HttpRequest::getOptions()</a></li>
1098 <li><a href="#HttpRequest_setSslOptions">HttpRequest::setSslOptions()</a></li>
1099 <li><a href="#HttpRequest_addSslOptions">HttpRequest::addSslOptions()</a></li>
1100 <li><a href="#HttpRequest_getSslOptions">HttpRequest::getSslOptions()</a></li>
1101 <li><a href="#HttpRequest_addHeaders">HttpRequest::addHeaders()</a></li>
1102 <li><a href="#HttpRequest_setHeaders">HttpRequest::setHeaders()</a></li>
1103 <li><a href="#HttpRequest_getHeaders">HttpRequest::getHeaders()</a></li>
1104 <li><a href="#HttpRequest_setCookies">HttpRequest::setCookies()</a></li>
1105 <li><a href="#HttpRequest_addCookies">HttpRequest::addCookies()</a></li>
1106 <li><a href="#HttpRequest_getCookies">HttpRequest::getCookies()</a></li>
1107 <li><a href="#HttpRequest_setUrl">HttpRequest::setUrl()</a></li>
1108 <li><a href="#HttpRequest_getUrl">HttpRequest::getUrl()</a></li>
1109 <li><a href="#HttpRequest_setMethod">HttpRequest::setMethod()</a></li>
1110 <li><a href="#HttpRequest_getMethod">HttpRequest::getMethod()</a></li>
1111 <li><a href="#HttpRequest_setContentType">HttpRequest::setContentType()</a></li>
1112 <li><a href="#HttpRequest_getContentType">HttpRequest::getContentType()</a></li>
1113 <li><a href="#HttpRequest_setQueryData">HttpRequest::setQueryData()</a></li>
1114 <li><a href="#HttpRequest_getQueryData">HttpRequest::getQueryData()</a></li>
1115 <li><a href="#HttpRequest_addQueryData">HttpRequest::addQueryData()</a></li>
1116 <li><a href="#HttpRequest_addPostFields">HttpRequest::addPostFields()</a></li>
1117 <li><a href="#HttpRequest_setPostFields">HttpRequest::setPostFields()</a></li>
1118 <li><a href="#HttpRequest_getPostFields">HttpRequest::getPostFields()</a></li>
1119 <li><a href="#HttpRequest_setRawPostData">HttpRequest::setRawPostData()</a></li>
1120 <li><a href="#HttpRequest_addRawPostData">HttpRequest::addRawPostData()</a></li>
1121 <li><a href="#HttpRequest_getRawPostData">HttpRequest::getRawPostData()</a></li>
1122 <li><a href="#HttpRequest_addPostFile">HttpRequest::addPostFile()</a></li>
1123 <li><a href="#HttpRequest_setPostFiles">HttpRequest::setPostFiles()</a></li>
1124 <li><a href="#HttpRequest_getPostFiles">HttpRequest::getPostFiles()</a></li>
1125 <li><a href="#HttpRequest_setPutFile">HttpRequest::setPutFile()</a></li>
1126 <li><a href="#HttpRequest_getPutFile">HttpRequest::getPutFile()</a></li>
1127 <li><a href="#HttpRequest_getResponseData">HttpRequest::getResponseData()</a></li>
1128 <li><a href="#HttpRequest_getResponseHeader">HttpRequest::getResponseHeader()</a></li>
1129 <li><a href="#HttpRequest_getResponseCookie">HttpRequest::getResponseCookie()</a></li>
1130 <li><a href="#HttpRequest_getResponseBody">HttpRequest::getResponseBody()</a></li>
1131 <li><a href="#HttpRequest_getResponseCode">HttpRequest::getResponseCode()</a></li>
1132 <li><a href="#HttpRequest_getResponseInfo">HttpRequest::getResponseInfo()</a></li>
1133 <li><a href="#HttpRequest_getResponseMessage">HttpRequest::getResponseMessage()</a></li>
1134 <li><a href="#HttpRequest_getRequestMessage">HttpRequest::getRequestMessage()</a></li>
1135 <li><a href="#HttpRequest_getHistory">HttpRequest::getHistory()</a></li>
1136 <li><a href="#HttpRequest_clearHistory">HttpRequest::clearHistory()</a></li>
1137 <li><a href="#HttpRequest_send">HttpRequest::send()</a></li>
1138 </li>
1139 </ul>
1140 </li>
1141 <li><a href="#http_requestpool_object.c">http_requestpool_object.c
1142 <ul>
1143 <li><a href="#HttpRequestPool___construct">HttpRequestPool::__construct()</a></li>
1144 <li><a href="#HttpRequestPool___destruct">HttpRequestPool::__destruct()</a></li>
1145 <li><a href="#HttpRequestPool_reset">HttpRequestPool::reset()</a></li>
1146 <li><a href="#HttpRequestPool_attach">HttpRequestPool::attach()</a></li>
1147 <li><a href="#HttpRequestPool_detach">HttpRequestPool::detach()</a></li>
1148 <li><a href="#HttpRequestPool_send">HttpRequestPool::send()</a></li>
1149 <li><a href="#HttpRequestPool_socketPerform">HttpRequestPool::socketPerform()</a></li>
1150 <li><a href="#HttpRequestPool_socketSelect">HttpRequestPool::socketSelect()</a></li>
1151 <li><a href="#HttpRequestPool_valid">HttpRequestPool::valid()</a></li>
1152 <li><a href="#HttpRequestPool_current">HttpRequestPool::current()</a></li>
1153 <li><a href="#HttpRequestPool_key">HttpRequestPool::key()</a></li>
1154 <li><a href="#HttpRequestPool_next">HttpRequestPool::next()</a></li>
1155 <li><a href="#HttpRequestPool_rewind">HttpRequestPool::rewind()</a></li>
1156 <li><a href="#HttpRequestPool_count">HttpRequestPool::count()</a></li>
1157 <li><a href="#HttpRequestPool_getAttachedRequests">HttpRequestPool::getAttachedRequests()</a></li>
1158 <li><a href="#HttpRequestPool_getFinishedRequests">HttpRequestPool::getFinishedRequests()</a></li>
1159 </li>
1160 </ul>
1161 </li>
1162 <li><a href="#http_response_object.c">http_response_object.c
1163 <ul>
1164 <li><a href="#HttpResponse_setHeader">HttpResponse::setHeader()</a></li>
1165 <li><a href="#HttpResponse_getHeader">HttpResponse::getHeader()</a></li>
1166 <li><a href="#HttpResponse_setCache">HttpResponse::setCache()</a></li>
1167 <li><a href="#HttpResponse_getCache">HttpResponse::getCache()</a></li>
1168 <li><a href="#HttpResponse_setGzip">HttpResponse::setGzip()</a></li>
1169 <li><a href="#HttpResponse_getGzip">HttpResponse::getGzip()</a></li>
1170 <li><a href="#HttpResponse_setCacheControl">HttpResponse::setCacheControl()</a></li>
1171 <li><a href="#HttpResponse_getCacheControl">HttpResponse::getCacheControl()</a></li>
1172 <li><a href="#HttpResponse_setContentType">HttpResponse::setContentType()</a></li>
1173 <li><a href="#HttpResponse_getContentType">HttpResponse::getContentType()</a></li>
1174 <li><a href="#HttpResponse_guessContentType">HttpResponse::guessContentType()</a></li>
1175 <li><a href="#HttpResponse_setContentDisposition">HttpResponse::setContentDisposition()</a></li>
1176 <li><a href="#HttpResponse_getContentDisposition">HttpResponse::getContentDisposition()</a></li>
1177 <li><a href="#HttpResponse_setETag">HttpResponse::setETag()</a></li>
1178 <li><a href="#HttpResponse_getETag">HttpResponse::getETag()</a></li>
1179 <li><a href="#HttpResponse_setLastModified">HttpResponse::setLastModified()</a></li>
1180 <li><a href="#HttpResponse_getLastModified">HttpResponse::getLastModified()</a></li>
1181 <li><a href="#HttpResponse_setThrottleDelay">HttpResponse::setThrottleDelay()</a></li>
1182 <li><a href="#HttpResponse_getThrottleDelay">HttpResponse::getThrottleDelay()</a></li>
1183 <li><a href="#HttpResponse_setBufferSize">HttpResponse::setBufferSize()</a></li>
1184 <li><a href="#HttpResponse_getBufferSize">HttpResponse::getBufferSize()</a></li>
1185 <li><a href="#HttpResponse_setData">HttpResponse::setData()</a></li>
1186 <li><a href="#HttpResponse_getData">HttpResponse::getData()</a></li>
1187 <li><a href="#HttpResponse_setStream">HttpResponse::setStream()</a></li>
1188 <li><a href="#HttpResponse_getStream">HttpResponse::getStream()</a></li>
1189 <li><a href="#HttpResponse_setFile">HttpResponse::setFile()</a></li>
1190 <li><a href="#HttpResponse_getFile">HttpResponse::getFile()</a></li>
1191 <li><a href="#HttpResponse_send">HttpResponse::send()</a></li>
1192 <li><a href="#HttpResponse_capture">HttpResponse::capture()</a></li>
1193 </li>
1194 </ul>
1195 </li>
1196 </ul>
1197 </div>
1198 <p><b>Generated at: Wed, 14 Dec 2005 16:25:48 +0100</b></p>
1199 </body>
1200 </html>
1201