the SERVER_NAME or just localhost if prior are not available.<br />
If a port is pecified in either the url or as sperate parameter,<br />
it will be added if it differs from te default port for HTTP(S).</p>
-<p>Returns the absolute URI as string.</p>
+<p>Returns the absolute URI as string on success or false on failure.</p>
<p>Examples:</p><pre><blockquote><code><span style="color: #000000"><br />
<span style="color: #0000BB"><?php<br />$uri </span><span style="color: #007700">= </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">, </span><span style="color: #DD0000">"https"</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #0000BB">488</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span><br />
</span></code></blockquote></p>
<h3 id="HttpRequest_setMethod">bool HttpRequest::setMethod(int request_method)</h3>
<p>Set the request method.</p>
<p>Expects an int as parameter specifying the request method to use.<br />
-In PHP 5.1+ HttpRequest::METH, otherwise the HTTP_METH constants can be used.</p>
+In PHP 5.1+ HttpRequest::METH_*, otherwise the HTTP_METH_* constants can be used.</p>
<p>Returns TRUE on success, or FALSE on failure.</p>
<h3 id="HttpRequest_getMethod">int HttpRequest::getMethod()</h3>
<p>Get the previously set request method.</p>
<p>Throws HttpRuntimeException, HttpRequestException, <br />
HttpMalformedHeaderException, HttpEncodingException.</p>
<p>GET example:</p><pre><blockquote><code><span style="color: #000000"><br />
-<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 />try {<br /> </span><span style="color: #0000BB">$r</span><span style="color: #007700">-></span><span style="color: #0000BB">send</span><span style="color: #007700">();<br /> if (</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 />} catch (</span><span style="color: #0000BB">HttpException $ex</span><span style="color: #007700">) {<br /> echo </span><span style="color: #0000BB">$ex</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span><br />
+<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">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">-></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 />try {<br /> </span><span style="color: #0000BB">$r</span><span style="color: #007700">-></span><span style="color: #0000BB">send</span><span style="color: #007700">();<br /> if (</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 />} catch (</span><span style="color: #0000BB">HttpException $ex</span><span style="color: #007700">) {<br /> echo </span><span style="color: #0000BB">$ex</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span><br />
</span></code></blockquote></p>
<p></pre></p>
<p>POST example:</p><pre><blockquote><code><span style="color: #000000"><br />
-<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">addPostFields</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 />try {<br /> echo </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">getBody</span><span style="color: #007700">();<br />} catch (</span><span style="color: #0000BB">HttpException $ex</span><span style="color: #007700">) {<br /> echo </span><span style="color: #0000BB">$ex</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span><br />
+<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">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">-></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">addPostFields</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 />try {<br /> echo </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">getBody</span><span style="color: #007700">();<br />} catch (</span><span style="color: #0000BB">HttpException $ex</span><span style="color: #007700">) {<br /> echo </span><span style="color: #0000BB">$ex</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span><br />
</span></code></blockquote></p>
<p></pre></p>
<hr noshade>
object while you're using the implemented Interator interface. </p>
<p>Accepts virtual infinite optional parameters each referencing an<br />
HttpRequest object.</p>
-<p>Throws HttpRequestException, HttpRequestPoolException, HttpInvalidParamException.</p>
+<p>Throws HttpRequestPoolException (HttpRequestException, HttpInvalidParamException).</p>
<p>Example:</p><pre><blockquote><code><span style="color: #000000"><br />
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">try {<br /> </span><span style="color: #0000BB">$pool </span><span style="color: #007700">= new </span><span style="color: #0000BB">HttpRequestPool</span><span style="color: #007700">(<br /> new </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">, </span><span style="color: #0000BB">HttpRequest</span><span style="color: #007700">::</span><span style="color: #0000BB">METH_HEAD</span><span style="color: #007700">),<br /> new </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">, </span><span style="color: #0000BB">HttpRequest</span><span style="color: #007700">::</span><span style="color: #0000BB">METH_HEAD</span><span style="color: #007700">)<br /> );<br /> </span><span style="color: #0000BB">$pool</span><span style="color: #007700">-></span><span style="color: #0000BB">send</span><span style="color: #007700">();<br /> foreach(</span><span style="color: #0000BB">$pool </span><span style="color: #007700">as </span><span style="color: #0000BB">$request</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%s is %s (%d)\n"</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">$request</span><span style="color: #007700">-></span><span style="color: #0000BB">getUrl</span><span style="color: #007700">(),<br /> </span><span style="color: #0000BB">$request</span><span style="color: #007700">-></span><span style="color: #0000BB">getResponseCode</span><span style="color: #007700">() ? </span><span style="color: #DD0000">'alive' </span><span style="color: #007700">: </span><span style="color: #DD0000">'not alive'</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">$request</span><span style="color: #007700">-></span><span style="color: #0000BB">getResponseCode</span><span style="color: #007700">()<br /> );<br /> }<br />} catch (</span><span style="color: #0000BB">HttpException $e</span><span style="color: #007700">) {<br /> echo </span><span style="color: #0000BB">$e</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span><br />
</span></code></blockquote></p>
<h3 id="HttpRequestPool_send">bool HttpRequestPool::send()</h3>
<p>Send all attached HttpRequest objects in parallel.</p>
<p>Returns TRUE on success, or FALSE on failure.</p>
-<p>Throws HttpSocketException, HttpRequestException, <br />
-HttpRequestPoolException, HttpMalformedHeaderException.</p>
+<p>Throws HttpRequestPoolException (HttpSocketException, HttpRequestException, HttpMalformedHeaderException).</p>
<h3 id="HttpRequestPool_socketPerform">protected bool HttpRequestPool::socketPerform()</h3>
<p>Returns TRUE until each request has finished its transaction.</p>
<p>Usage:</p><pre><blockquote><code><span style="color: #000000"><br />
</li>
</ul>
</div>
- <p><b>Generated at: Mon, 21 Nov 2005 16:56:18 +0100</b></p>
+ <p><b>Generated at: Fri, 09 Dec 2005 13:56:42 +0100</b></p>
</body>
</html>
decoded_len = Z_STRLEN(retval); \
} \
}
+
+# define REMEMBER_ENCODING() \
+ if (decoded) { \
+ ZVAL_ADDREF(c); \
+ zend_hash_add(&msg->hdrs, "X-Original-Content-Encoding", sizeof("X-Original-Content-Encoding"), (void *) &c, sizeof(zval *), NULL); \
+ }
if (!strcasecmp(Z_STRVAL_P(c), "gzip") || !strcasecmp(Z_STRVAL_P(c), "x-gzip")) {
# ifdef HTTP_HAVE_ZLIB
ZVAL_STRINGL(&arg, PHPSTR_VAL(msg) + 10, PHPSTR_LEN(msg) - 18, 0);
DECODE_WITH_EXT_ZLIB();
# endif /* HTTP_HAVE_ZLIB */
+ REMEMBER_ENCODING();
} else if (!strcasecmp(Z_STRVAL_P(c), "deflate")) {
# ifdef HTTP_HAVE_ZLIB
http_encoding_inflate(PHPSTR_VAL(msg), PHPSTR_LEN(msg), &decoded, &decoded_len);
ZVAL_STRINGL(&arg, PHPSTR_VAL(msg), PHPSTR_LEN(msg), 0);
DECODE_WITH_EXT_ZLIB();
# endif /* HTTP_HAVE_ZLIB */
+ REMEMBER_ENCODING();
}
if (decoded) {
- zval *len;
+ zval *len, **original_len;
char *tmp;
int tmp_len;
ZVAL_STRINGL(len, tmp, tmp_len, 0);
zend_hash_del(&msg->hdrs, "Content-Encoding", sizeof("Content-Encoding"));
- zend_hash_del(&msg->hdrs, "Content-Length", sizeof("Content-Length"));
- zend_hash_add(&msg->hdrs, "Content-Length", sizeof("Content-Length"), (void *) &len, sizeof(zval *), NULL);
-
+ if (zend_hash_find(&msg->hdrs, "Content-Length", sizeof("Content-Length"), (void **) &original_len) == SUCCESS) {
+ ZVAL_ADDREF(*original_len);
+ zend_hash_add(&msg->hdrs, "X-Original-Content-Length", sizeof("X-Original-Content-Length"), (void *) original_len, sizeof(zval *), NULL);
+ zend_hash_update(&msg->hdrs, "Content-Length", sizeof("Content-Length"), (void *) &len, sizeof(zval *), NULL);
+ } else {
+ zend_hash_add(&msg->hdrs, "Content-Length", sizeof("Content-Length"), (void *) &len, sizeof(zval *), NULL);
+ }
+
phpstr_dtor(PHPSTR(msg));
PHPSTR(msg)->data = decoded;
PHPSTR(msg)->used = decoded_len;