/* {{{ STATUS http_exit(int, char*, char*) */
STATUS _http_exit_ex(int status, char *header, char *body, zend_bool send_header TSRMLS_DC)
{
- if (status || send_header) {
- if (SUCCESS != http_send_status_header(status, send_header ? header : NULL)) {
- http_error_ex(HE_WARNING, HTTP_E_HEADER, "Failed to exit with status/header: %d - %s", status, header ? header : "");
- STR_FREE(header);
- STR_FREE(body);
- return FAILURE;
- }
+ if ( (send_header && (SUCCESS != http_send_status_header(status, header))) ||
+ (!send_header && status && (SUCCESS != http_send_status(status)))) {
+ http_error_ex(HE_WARNING, HTTP_E_HEADER, "Failed to exit with status/header: %d - %s", status, header ? header : "");
+ STR_FREE(header);
+ STR_FREE(body);
+ return FAILURE;
}
if (php_header(TSRMLS_C) && body) {
# endif /* HTTP_HAVE_ZLIB */
}
- if (decoded && decoded_len) {
+ if (decoded) {
zval *len;
char *tmp;
int tmp_len;
RETVAL_OBJECT(o); \
return
#define RETVAL_OBJVAL(ov) \
- ZVAL_OBJVAL(return_value, ov)
+ ZVAL_OBJVAL(return_value, ov) \
+ if (Z_OBJ_HT_P(return_value)->add_ref) { \
+ Z_OBJ_HT_P(return_value)->add_ref(return_value TSRMLS_CC); \
+ }
#define RETURN_OBJVAL(ov) \
RETVAL_OBJVAL(ov); \
return
#define ZVAL_OBJVAL(zv, ov) \
(zv)->type = IS_OBJECT; \
- (zv)->value.obj = (ov); \
- if (Z_OBJ_HT_P(zv)->add_ref) { \
- Z_OBJ_HT_P(zv)->add_ref((zv) TSRMLS_CC); \
- }
-
+ (zv)->value.obj = (ov);
+
/* function accepts no args */
#define NO_ARGS \
if (ZEND_NUM_ARGS()) { \
"HTTP/1.1 301\r\n".
"Location: /anywhere\r\n".
"HTTP/1.1 302\r\n".
- "Location: /somwhere\r\n".
+ "Location: /somewhere\r\n".
"HTTP/1.1 206\r\n".
"Content-Range: bytes=2-3\r\n".
"Transfer-Encoding: chunked\r\n".
);
var_dump($m->getBody());
-var_dump($m->toString(true));
var_dump(HttpMessage::fromString($m->toString(true))->toString(true));
+do {
+ var_dump($m->toString());
+} while ($m = $m->getParentMessage());
+
+echo "Done\n";
?>
--EXPECTF--
%sTEST
string(1) "X"
-string(134) "HTTP/1.1 301
+string(135) "HTTP/1.1 301
Location: /anywhere
HTTP/1.1 302
-Location: /somwhere
+Location: /somewhere
HTTP/1.1 206
Content-Range: bytes=2-3
Content-Length: 1
X
"
-string(134) "HTTP/1.1 301
-Location: /anywhere
-HTTP/1.1 302
-Location: /somwhere
-HTTP/1.1 206
+string(64) "HTTP/1.1 206
Content-Range: bytes=2-3
Content-Length: 1
X
"
-
+string(36) "HTTP/1.1 302
+Location: /somewhere
+"
+string(35) "HTTP/1.1 301
+Location: /anywhere
+"
+Done
$r = new HttpRequest('https://ssl.arweb.info/iworks/data.txt');
$r->send();
var_dump($r->getResponseBody());
+var_dump(is_object($r->getResponseMessage()));
+var_dump(is_object($r->getResponseMessage()));
+var_dump(is_object($r->getResponseMessage()));
?>
--EXPECTF--
%sTEST
string(10) "1234567890"
-
+bool(true)
+bool(true)
+bool(true)