Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
REST Module Treats Header Names Case-Sensitively #3516
When encoding parameters, the REST module compares HTTP headers in a case-sensitive manner, which can prevent parameters from being encoded/sent with the request in some circumstances (e.g., when sending params as json).
RFC 2616 specifies that HTTP header names are case-insensitive.
Steps to reproduce:
<?php $request_body = file_get_contents('php://input'); echo 'request body length: ', strlen($request_body), "\n", "request body contents: \n", $request_body, "\n--end--\n";
<?php $I = new AcceptanceTester($scenario); $params = ['foo' => 'foo', 'bar' => 'bar']; $I->haveHttpHeader('Content-type', 'application/json'); $I->sendPost('/test_subject.php', $params); echo "case-insensitive:\n", $I->grabResponse(); $I->haveHttpHeader('Content-Type', 'application/json'); $I->sendPost('/test_subject.php', $params); echo "\ncase-sensitive:\n", $I->grabResponse();
Because http headers are case-insensitive, both headers should be seen as the same header, and therefore, both requests should be identical and should result in identical responses.
The first request (which sets the header as "Content-type"; note capitalization) fails to encode and send the parameters with the request.
class_name: AcceptanceTester modules: enabled: - REST: url: https://localhost/demo depends: PhpBrowser