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