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

From: Date: Sat, 24 Nov 2001 23:48:44 +0000
Subject: Bug #14207 Updated: HTTP_RAW_POST_DATA not set for known content types - fix supplied
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-71559@lists.php.net to get a copy of this message
ID: 14207 Updated by: sniper Reported By: duncan@emarketeers.com Old Status: Open Status: Closed Bug Type: Feature/Change Request Operating System: All PHP Version: 4.0.6 New Comment: This is fixed in latest CVS. Try a snapshot from http://snaps.php.net/ and note that you need to set the 'always_populate_raw_post_data=On' in php.ini. --Jani Previous Comments: ------------------------------------------------------------------------ [2001-11-24 08:42:39] duncan@emarketeers.com 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 this bug report at http://bugs.php.net/?id=14207&edit=1

« previous php.dev (#71559) next »