svn: /pecl/http/branches/DEV_2/ php_http_env_response.c
| From: | Michael Wallner | Date: | Fri, 08 Nov 2013 20:24:07 +0000 |
| Subject: | svn: /pecl/http/branches/DEV_2/ php_http_env_response.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-19979@lists.php.net to get a copy of this message | ||
mike Fri, 08 Nov 2013 20:24:07 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=332087
Log:
consolidate return values
Changed paths:
U pecl/http/branches/DEV_2/php_http_env_response.c
Modified: pecl/http/branches/DEV_2/php_http_env_response.c
===================================================================
--- pecl/http/branches/DEV_2/php_http_env_response.c 2013-11-08 12:58:59 UTC (rev 332086)
+++ pecl/http/branches/DEV_2/php_http_env_response.c 2013-11-08 20:24:07 UTC (rev 332087)
@@ -1103,6 +1103,7 @@
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|O", &env_req,
php_http_message_class_entry)) {
set_option(getThis(), ZEND_STRL("request"), IS_OBJECT, env_req, 0 TSRMLS_CC);
+ RETVAL_ZVAL(getThis(), 1, 0);
}
}
@@ -1116,6 +1117,7 @@
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!", &ct_str,
&ct_len)) {
set_option(getThis(), ZEND_STRL("contentType"), IS_STRING, ct_str, ct_len TSRMLS_CC);
+ RETVAL_ZVAL(getThis(), 1, 0);
}
}
@@ -1128,6 +1130,7 @@
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &zdisposition))
{
zend_update_property(Z_OBJCE_P(getThis()), getThis(), ZEND_STRL("contentDisposition"),
zdisposition TSRMLS_CC);
+ RETVAL_ZVAL(getThis(), 1, 0);
}
}
@@ -1140,6 +1143,7 @@
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ce)) {
set_option(getThis(), ZEND_STRL("contentEncoding"), IS_LONG, &ce, 0 TSRMLS_CC);
+ RETVAL_ZVAL(getThis(), 1, 0);
}
}
@@ -1153,6 +1157,7 @@
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!", &cc_str,
&cc_len)) {
set_option(getThis(), ZEND_STRL("cacheControl"), IS_STRING, cc_str, cc_len TSRMLS_CC);
+ RETVAL_ZVAL(getThis(), 1, 0);
}
}
@@ -1165,6 +1170,7 @@
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
&last_modified)) {
set_option(getThis(), ZEND_STRL("lastModified"), IS_LONG, &last_modified, 0
TSRMLS_CC);
+ RETVAL_ZVAL(getThis(), 1, 0);
}
}
@@ -1184,7 +1190,6 @@
RETURN_LONG(php_http_env_is_response_cached_by_last_modified(getThis(), header_name_str,
header_name_len, get_request(getThis() TSRMLS_CC) TSRMLS_CC));
}
- RETURN_FALSE;
}
ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_setEtag, 0, 0, 1)
@@ -1197,6 +1202,7 @@
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!", &etag_str,
&etag_len)) {
set_option(getThis(), ZEND_STRL("etag"), IS_STRING, etag_str, etag_len TSRMLS_CC);
+ RETVAL_ZVAL(getThis(), 1, 0);
}
}
@@ -1215,7 +1221,6 @@
}
RETURN_LONG(php_http_env_is_response_cached_by_etag(getThis(), header_name_str, header_name_len,
get_request(getThis() TSRMLS_CC) TSRMLS_CC));
}
- RETURN_FALSE;
}
ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_setThrottleRate, 0, 0, 1)
@@ -1230,39 +1235,46 @@
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|d", &chunk_size,
&delay)) {
set_option(getThis(), ZEND_STRL("throttleDelay"), IS_DOUBLE, &delay, 0 TSRMLS_CC);
set_option(getThis(), ZEND_STRL("throttleChunk"), IS_LONG, &chunk_size, 0
TSRMLS_CC);
- RETURN_TRUE;
+ RETVAL_ZVAL(getThis(), 1, 0);
}
- RETURN_FALSE;
}
ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_send, 0, 0, 0)
+ ZEND_ARG_INFO(0, stream)
ZEND_END_ARG_INFO();
static PHP_METHOD(HttpEnvResponse, send)
{
zval *zstream = NULL;
php_stream *s = NULL;
- RETVAL_FALSE;
-
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &zstream)) {
+ /* first flush the output layer to avoid conflicting headers and output;
+ * also, ob_start($thisEnvResponse) might have been called */
+#if PHP_VERSION_ID >= 50400
+ php_output_end_all(TSRMLS_C);
+#else
+ php_end_ob_buffers(1 TSRMLS_CC);
+#endif
if (zstream) {
- php_stream_from_zval_no_verify(s, &zstream);
+ php_http_env_response_t *r;
- if (s) {
- php_http_env_response_t *r;
+ php_stream_from_zval(s, &zstream);
+ r = php_http_env_response_init(NULL, getThis(), php_http_env_response_get_stream_ops(), s
TSRMLS_CC);
+ if (!r) {
+ RETURN_FALSE;
+ }
- if ((r = php_http_env_response_init(NULL, getThis(), php_http_env_response_get_stream_ops(), s
TSRMLS_CC))) {
- RETVAL_BOOL(SUCCESS == php_http_env_response_send(r));
- php_http_env_response_free(&r);
- }
- }
+ RETVAL_BOOL(SUCCESS == php_http_env_response_send(r));
+ php_http_env_response_free(&r);
} else {
php_http_env_response_t r;
- if (php_http_env_response_init(&r, getThis(), NULL, NULL TSRMLS_CC)) {
- RETVAL_BOOL(SUCCESS == php_http_env_response_send(&r));
- php_http_env_response_dtor(&r);
+ if (!php_http_env_response_init(&r, getThis(), NULL, NULL TSRMLS_CC)) {
+ RETURN_FALSE;
}
+
+ RETVAL_BOOL(SUCCESS == php_http_env_response_send(&r));
+ php_http_env_response_dtor(&r);
}
}
}