Bug #14207: HTTP_RAW_POST_DATA not set for known content types - fix supplied

From: Date: Sat, 24 Nov 2001 13:42:40 +0000
Subject: Bug #14207: HTTP_RAW_POST_DATA not set for known content types - fix supplied
Groups: php.dev 
Request: Send a blank email to php-dev+get-71528@lists.php.net to get a copy of this message
From: duncan@emarketeers.com Operating system: All PHP version: 4.0.6 PHP Bug Type: Feature/Change Request Bug description: HTTP_RAW_POST_DATA not set for known content types - fix supplied The global variable HTTP_RAW_POST_VARS does not get set unless the content-type is unknown to php. This causes problems when a remote server POSTs information which has Content-type:application/x-www-form-urlencoded but the server actually posts something different. Using ASP or perl, one can simply open stdin to get the raw data, however this facility does not exist in PHP. Applications I know of which POST this kind of data include a number of SOAP servers and some credit-card authorizers, notably BarclaysEPDQ. In order to interface to these servers some perl glue is necessary. I know that this issue affects quite a few people - just search for HTTP_RAW_POST_DATA on Google. The fix is simple - a short patch to main/php_variables.c. The diff over the code in the 4.0.6 distribution is as follows, complete code for the affected function (php_std_post_handler) is also given. ======== diff ============ 197d196 < char *data; 202,207d200 < /* Make sure we always set HTTP_RAW_POST_DATA */ < sapi_read_standard_form_data(SLS_C); < data = estrndup(SG(request_info).post_data,SG(request_info).post_data_length); < SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, SG(request_info).post_data_length); < < ========= end diff ======== ====== function ========== SAPI_POST_HANDLER_FUNC(php_std_post_handler) { char *var, *val; char *strtok_buf = NULL; char *data; zval *array_ptr = (zval *) arg; ELS_FETCH(); PLS_FETCH(); /* Make sure we always set HTTP_RAW_POST_DATA */ sapi_read_standard_form_data(SLS_C); data = estrndup(SG(request_info).post_data,SG(request_info).post_data_length); SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, SG(request_info).post_data_length); var = php_strtok_r(SG(request_info).post_data, "&", &strtok_buf); while (var) { val = strchr(var, '='); if (val) { /* have a value */ int val_len; *val++ = '\0'; php_url_decode(var, strlen(var)); val_len = php_url_decode(val, strlen(val)); php_register_variable_safe(var, val, val_len, array_ptr ELS_CC PLS_CC); } var = php_strtok_r(NULL, "&", &strtok_buf); } } ========= end function ============ -- Edit bug report at: http://bugs.php.net/?id=14207&edit=1

« previous php.dev (#71528) next »