Skip to content

Commit

Permalink
Merge pull request #1098 from sjinks/issue-1091
Browse files Browse the repository at this point in the history
Fix #1091
  • Loading branch information
Phalcon committed Aug 16, 2013
2 parents d318426 + 5e6f676 commit ee12592
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions ext/http/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ PHALCON_INIT_CLASS(Phalcon_Http_Request){

zend_declare_property_null(phalcon_http_request_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(phalcon_http_request_ce, SL("_filter"), ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(phalcon_http_request_ce, SL("_rawBody"), ZEND_ACC_PROTECTED TSRMLS_CC);

zend_class_implements(phalcon_http_request_ce TSRMLS_CC, 2, phalcon_http_requestinterface_ce, phalcon_di_injectionawareinterface_ce);

Expand Down Expand Up @@ -593,11 +594,23 @@ PHP_METHOD(Phalcon_Http_Request, isSecureRequest){
*/
PHP_METHOD(Phalcon_Http_Request, getRawBody){

zval *raw;
if (SG(request_info).raw_post_data) {
RETURN_STRINGL(SG(request_info).raw_post_data, SG(request_info).raw_post_data_length, 1);
}

if (sapi_module.read_post) {
raw = phalcon_fetch_nproperty_this(getThis(), SL("_rawBody"), PH_NOISY TSRMLS_CC);
if (Z_TYPE_P(raw) == IS_STRING) {
if (return_value_ptr) {
zval_ptr_dtor(return_value_ptr);
*return_value_ptr = raw;
Z_ADDREF_P(raw);
}
else {
RETURN_ZVAL(raw, 1, 0);
}
}
else if (sapi_module.read_post) {
int read_bytes;
char *buf = emalloc(8192);
smart_str raw_data = { NULL, 0, 0 };
Expand All @@ -609,11 +622,18 @@ PHP_METHOD(Phalcon_Http_Request, getRawBody){

efree(buf);
if (raw_data.c) {
RETURN_STRINGL(raw_data.c, raw_data.len, 0);
smart_str_0(&raw_data);
RETVAL_STRINGL(raw_data.c, raw_data.len, 0);
}
else {
RETVAL_EMPTY_STRING();
}
}

RETURN_EMPTY_STRING();
phalcon_update_property_this(getThis(), SL("_rawBody"), return_value TSRMLS_CC);
}
else {
RETURN_EMPTY_STRING();
}
}

/**
Expand Down

0 comments on commit ee12592

Please sign in to comment.