mirror of
https://github.com/GeoffreyFrogeye/phroxyp.git
synced 2024-11-23 19:56:02 +01:00
Proper support for application/x-www-form-urlencoded
Now that I know how it's called
This commit is contained in:
parent
61ca4039e7
commit
3c851c6e28
27
proxy.php
27
proxy.php
|
@ -20,7 +20,7 @@ class Proxy {
|
||||||
|
|
||||||
$headers = array();
|
$headers = array();
|
||||||
foreach ($_SERVER as $name => $value) {
|
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;
|
$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
|
// Converting client request headers to server request headers
|
||||||
$reqsHedsC = getallheaders();
|
$reqsHedsC = getallheaders();
|
||||||
foreach ($reqsHedsC as $name => $content) {
|
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";
|
$reqHeds .= "$name: $content\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($metd == 'POST') { // TODO Other with data methods
|
if (isset($reqsHedsC['Content-Type'])) {
|
||||||
if (isset($_POST['payload'])) {
|
switch ($reqsHedsC['Content-Type']) { // TODO Other content-types
|
||||||
$postData = stripslashes($_POST['payload']);
|
case 'application/x-www-form-urlencoded':
|
||||||
} else {
|
|
||||||
$postData = '';
|
$postData = '';
|
||||||
foreach ($_POST as $key => $value) {
|
foreach ($_POST as $key => $value) {
|
||||||
$postData .= $key . '=' . urlencode($value) . '&';
|
$postData .= $key . '=' . urlencode($value) . '&';
|
||||||
}
|
}
|
||||||
$postData = rtrim($postData, '&');
|
$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 .= "Content-Length: ".strlen($postData)."\r\n";
|
||||||
$reqHeds .= "Connection: Close\r\n";
|
$reqHeds .= "Connection: Close\r\n";
|
||||||
|
|
Loading…
Reference in a new issue