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

REST Module Treats Header Names Case-Sensitively #3516

adrian-enspired opened this issue Sep 15, 2016 · 0 comments

REST Module Treats Header Names Case-Sensitively #3516

adrian-enspired opened this issue Sep 15, 2016 · 0 comments


Copy link

@adrian-enspired adrian-enspired commented Sep 15, 2016

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.

4.2 Message Headers
HTTP header fields, which include general-header (section 4.5),
request-header (section 5.3), response-header (section 6.2), and
entity-header (section 7.1) fields, follow the same generic format as
that given in Section 3.1 of RFC 822 [9]. Each header field consists
of a name followed by a colon (":") and the field value. Field names
are case-insensitive.
[emphasis added]

Steps to reproduce:

Test Subject:


$request_body = file_get_contents('php://input');

echo 'request body length: ', strlen($request_body), "\n",
  "request body contents: \n", $request_body, "\n--end--\n";


$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();

Expected Results:

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.

Actual Results:

The first request (which sets the header as "Content-type"; note capitalization) fails to encode and send the parameters with the request.

Codeception PHP Testing Framework v2.2.3
Powered by PHPUnit 5.4.8 by Sebastian Bergmann and contributors.

Acceptance Tests (1) ----------------------------------------------------------------
- codeCept: 
request body length: 0
request body contents: 


request body length: 25
request body contents: 
✔ codeCept:  (0.07s)

Time: 290 ms, Memory: 30.00MB

OK (1 test, 0 assertions)


  • Codeception version: 2.2.3
  • PHP Version: 7.0.8
  • Operating System: Debian
  • Installation type: Composer
  • Suite configuration:
class_name: AcceptanceTester
        - REST:
            url: https://localhost/demo
            depends: PhpBrowser
@Naktibalda Naktibalda added the REST label Sep 15, 2016
Naktibalda added a commit to Naktibalda/Codeception that referenced this issue Sep 16, 2016
chris1312 pushed a commit to chris1312/Codeception that referenced this issue Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.