Skip to content

Instantly share code, notes, and snippets.

@stephenreay
Created May 18, 2019 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenreay/2dc75d4042c261ee790fa0ead98f8785 to your computer and use it in GitHub Desktop.
Save stephenreay/2dc75d4042c261ee790fa0ead98f8785 to your computer and use it in GitHub Desktop.
HTTPie mangles input
php -S 127.0.0.1:8888 index.php > php.log 2>&1 &
curl 127.0.0.1:8888 -d foo=bar > curl.out 2>&1
http POST 127.0.0.1:8888 foo=bar > httpie.out 2>&1
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 133 0 126 100 7 183k 10416 --:--:-- --:--:-- --:--:-- 123k
Method:
string(4) "POST"
Get:
array(0) {
}
POST:
array(1) {
["foo"]=>
string(3) "bar"
}
Raw POST:
string(7) "foo=bar"
Method:
string(4) "POST"
Get:
array(0) {
}
POST:
array(0) {
}
Raw POST:
string(14) "{"foo": "bar"}"
<?php
echo 'Method:' . PHP_EOL;
var_dump($_SERVER['REQUEST_METHOD']);
echo PHP_EOL;
echo 'Get:'.PHP_EOL;
var_dump($_GET);
echo PHP_EOL;
echo 'POST:' .PHP_EOL;
var_dump($_POST);
echo PHP_EOL;
echo 'Raw POST:' . PHP_EOL;
var_dump(file_get_contents('php://input'));
echo PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment