Skip to content

Commit

Permalink
Fixed issue laruence#190
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Aug 30, 2015
1 parent 42ed1e4 commit 041949a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions responses/yaf_response_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,14 @@ int yaf_response_http_send(yaf_response_t *response TSRMLS_DC) {
zval **val, **entry;
char *header_name;
uint header_name_len;
ulong num_key;
ulong num_key;
HashPosition pos;
sapi_header_line ctr = {0};

zresponse_code = zend_read_property(yaf_response_ce, response, ZEND_STRL(YAF_RESPONSE_PROPERTY_NAME_RESPONSECODE), 1 TSRMLS_CC);
SG(sapi_headers).http_response_code = Z_LVAL_P(zresponse_code);
if (Z_LVAL_P(zresponse_code)) {
SG(sapi_headers).http_response_code = Z_LVAL_P(zresponse_code);
}

zheader = zend_read_property(yaf_response_ce, response, ZEND_STRL(YAF_RESPONSE_PROPERTY_NAME_HEADER), 1 TSRMLS_CC);
for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(zheader), &pos);
Expand Down Expand Up @@ -191,20 +193,20 @@ int yaf_response_http_send(yaf_response_t *response TSRMLS_DC) {
/** {{{ proto public Yaf_Response_Http::setHeader($name, $value, $replace = 0)
*/
PHP_METHOD(yaf_response_http, setHeader) {
zval *response_code = NULL;
long response_code = 0;
char *name, *value;
uint name_len, value_len;
zend_bool rep = 1;
yaf_response_t *self;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|bz", &name, &name_len, &value, &value_len, &rep, &response_code) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|bl", &name, &name_len, &value, &value_len, &rep, &response_code) == FAILURE) {
return;
}

self = getThis();

if (response_code) {
zend_update_property(yaf_response_ce, self, ZEND_STRL(YAF_RESPONSE_PROPERTY_NAME_RESPONSECODE), response_code TSRMLS_CC);
zend_update_property_long(yaf_response_ce, self, ZEND_STRL(YAF_RESPONSE_PROPERTY_NAME_RESPONSECODE), response_code TSRMLS_CC);
}

if (yaf_response_alter_header(self, name, name_len, value, value_len, rep ? 1 : 0 TSRMLS_CC)) {
Expand Down Expand Up @@ -337,7 +339,7 @@ YAF_STARTUP_FUNCTION(response_http) {
yaf_response_http_ce = zend_register_internal_class_ex(&ce, yaf_response_ce, NULL TSRMLS_CC);

zend_declare_property_bool(yaf_response_http_ce, ZEND_STRL(YAF_RESPONSE_PROPERTY_NAME_HEADEREXCEPTION), 1, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_long(yaf_response_http_ce, ZEND_STRL(YAF_RESPONSE_PROPERTY_NAME_RESPONSECODE), 200, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_long(yaf_response_http_ce, ZEND_STRL(YAF_RESPONSE_PROPERTY_NAME_RESPONSECODE), 0, ZEND_ACC_PROTECTED TSRMLS_CC);

return SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/026.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Yaf_Response_Http Object
)

[_sendheader:protected] => 1
[_response_code:protected] => 200
[_response_code:protected] => 0
)
Hello World
2 changes: 1 addition & 1 deletion tests/072.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Yaf_Response_Http Object
)

[_sendheader:protected] => 1
[_response_code:protected] => 200
[_response_code:protected] => 0
)
bool(true)
bool(true)
Expand Down

0 comments on commit 041949a

Please sign in to comment.