1
0
Fork 0
mirror of https://github.com/GeoffreyFrogeye/phroxyp.git synced 2024-05-02 19:16:44 +00:00

Proper support for application/x-www-form-urlencoded

Now that I know how it's called
This commit is contained in:
Geoffrey Frogeye 2015-04-09 23:14:30 +02:00
parent 61ca4039e7
commit 3c851c6e28

View file

@ -20,7 +20,7 @@ class Proxy {
$headers = array();
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
if (substr($name, 0, 5) == 'HTTP_' || substr($name, 0, 8) == 'CONTENT_') {
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
@ -42,20 +42,35 @@ class Proxy {
// Converting client request headers to server request headers
$reqsHedsC = getallheaders();
foreach ($reqsHedsC as $name => $content) {
if ($name != 'Host' && $name != 'Connection') { // TODO More analysis
switch ($name) {
case 'Host':
case 'Connection':
case 'Content-Length':
break;
default:
$reqHeds .= "$name: $content\r\n";
}
}
if ($metd == 'POST') { // TODO Other with data methods
if (isset($_POST['payload'])) {
$postData = stripslashes($_POST['payload']);
} else {
if (isset($reqsHedsC['Content-Type'])) {
switch ($reqsHedsC['Content-Type']) { // TODO Other content-types
case 'application/x-www-form-urlencoded':
$postData = '';
foreach ($_POST as $key => $value) {
$postData .= $key . '=' . urlencode($value) . '&';
}
$postData = rtrim($postData, '&');
break;
case 'TODO':
$postData = stripslashes($_POST['payload']);
break;
default:
$postData = "Unknown Content-Type";
break;
}
$reqHeds .= "Content-Length: ".strlen($postData)."\r\n";
$reqHeds .= "Connection: Close\r\n";