Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace network_confirm scripts with one request mirror script #19

Open
jakoch opened this issue Dec 12, 2015 · 0 comments
Open

replace network_confirm scripts with one request mirror script #19

jakoch opened this issue Dec 12, 2015 · 0 comments

Comments

@jakoch
Copy link
Member

jakoch commented Dec 12, 2015

We can remove some lines of code by de-duplicating the network_confirm.php code.
My suggestion is to use one central script for request mirroring.
The idea is to build a JSON response and use array/object access in tests.
(Basically a note for myself, before the idea gets lost.)
Quick draft:

$url = 'http://';
if (isset($_SERVER['HTTPS'])) {
    $url = 'https://';
}
$url .= "{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
if ($_SERVER['QUERY_STRING']) {
    $url .= "?{$_SERVER['QUERY_STRING']}";
}
$request = array(
    'body' => file_get_contents('php://input'),
    'headers' => getallheaders(),
    'origin' => $_SERVER['REMOTE_ADDR'],
    'method' => $_SERVER['REQUEST_METHOD'],
    'params' => array(
        'get' => $_GET,
        'post' => $_POST,
    ),
    'url' => $url,
);
header('Content-Type: application/json');
echo json_encode($request);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant