Skip to content

Commit b187b60

Browse files
committed
Check http-prefixed content-* headers
The built-in web server in PHP 5.4 sets the Content-Length and Content-Type headers in $_SERVER['HTTP_CONTENT_LENGTH'] and $_SERVER['HTTP_CONTENT_TYPE'] rather than $_SERVER['CONTENT_LENGTH'] and $_SERVER['CONTENT_TYPE'].
1 parent 75c6fbf commit b187b60

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

proxy.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@
234234
isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET' );
235235

236236
// Pass on content, regardless of request method
237-
if ( isset($_SERVER['CONTENT_LENGTH'] ) && $_SERVER['CONTENT_LENGTH'] > 0 ) {
237+
if ( (isset($_SERVER['CONTENT_LENGTH'] ) && $_SERVER['CONTENT_LENGTH'] > 0) ||
238+
(isset($_SERVER['HTTP_CONTENT_LENGTH'] ) && $_SERVER['HTTP_CONTENT_LENGTH'] > 0) ) {
238239
curl_setopt( $ch, CURLOPT_POSTFIELDS, file_get_contents("php://input") );
239240
}
240241

@@ -257,9 +258,12 @@
257258
array_push($headers, "Authorization: ".$_SERVER[$authz_header] );
258259
}
259260
if ( isset($_SERVER['CONTENT_TYPE']) ) {
260-
// Pass through the Content-Type header
261-
array_push($headers, "Content-Type: ".$_SERVER['CONTENT_TYPE'] );
262-
}
261+
// Pass through the Content-Type header
262+
array_push($headers, "Content-Type: ".$_SERVER['CONTENT_TYPE'] );
263+
} elseif ( isset($_SERVER['HTTP_CONTENT_TYPE']) ) {
264+
// Pass through the Content-Type header
265+
array_push($headers, "Content-Type: ".$_SERVER['HTTP_CONTENT_TYPE'] );
266+
}
263267
if ( isset($_SERVER['HTTP_X_USER_AGENT']) ) {
264268
// Pass through the X-User-Agent header
265269
array_push($headers, "X-User-Agent: ".$_SERVER['HTTP_X_USER_AGENT'] );

0 commit comments

Comments
 (0)