Skip to content

Commit 14175fd

Browse files
committed
Restore CONTENT headers and add variable for Expect
Restore CONTENT headers- it seems that from some clients PHP doesn't have the duplicate headers. Consider adding an `array_unique` to clean header array Wrap handling of Expect header in config variable.
1 parent 392a417 commit 14175fd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

proxy.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
*/
3030
define('CSAJAX_FILTER_DOMAIN', false);
3131

32+
/**
33+
* Enables or disables Expect: 100-continue header. Some webservers don't
34+
* handle this header correctly.
35+
* Recommended value: false
36+
*/
37+
define('CSAJAX_SUPPRESS_EXPECT', false);
38+
3239
/**
3340
* Set debugging to true to receive additional messages - really helpful on development
3441
*/
@@ -57,7 +64,7 @@
5764
// identify request headers
5865
$request_headers = array( );
5966
foreach ($_SERVER as $key => $value) {
60-
if (strpos($key, 'HTTP_') === 0 ) {
67+
if (strpos($key, 'HTTP_') === 0 || strpos($key, 'CONTENT_') === 0) {
6168
$headername = str_replace('_', ' ', str_replace('HTTP_', '', $key));
6269
$headername = str_replace(' ', '-', ucwords(strtolower($headername)));
6370
if (!in_array($headername, array( 'Host', 'X-Proxy-Url' ))) {
@@ -137,7 +144,12 @@
137144

138145
// let the request begin
139146
$ch = curl_init($request_url);
140-
array_push($request_headers, 'Expect:'); // Many hosts don't support 100-Expect
147+
148+
// Suppress Expect header
149+
if (CSAJAX_SUPPRESS_EXPECT) {
150+
array_push($request_headers, 'Expect:');
151+
}
152+
141153
curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers); // (re-)send headers
142154
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return response
143155
curl_setopt($ch, CURLOPT_HEADER, true); // enabled response headers

0 commit comments

Comments
 (0)