Skip to content

Sending Content-Length: 0 is optional for TRACE #33

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

Merged
merged 2 commits into from
Jul 10, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/HttpBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ protected function assertRequest(

$name = strtoupper(str_replace('-', '_', 'http-'.$name));

if ($method === 'TRACE' && $name === 'HTTP_CONTENT_LENGTH' && !isset($request['SERVER'][$name])) {
$request['SERVER'][$name] = '0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we add a fake content length? while this works, i would prefer to simply log a $this->success() and return instead. the assertions below make no sense if we just set the value.

i agree that if content length is set, it must be correctly at 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes everything more complicated. The test correctly asserts that there's a content-length: 0 or no header at all. While this specific assertion might be useless then, there are always non-useless assertions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but you could replace this line by return; and the test would still do the same, right? i would find that more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but can replace it with continue;, just did that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups, did not read the context :-)

}

$this->assertArrayHasKey($name, $request['SERVER']);
$this->assertSame($value, $request['SERVER'][$name], "Failed asserting value for {$name}.");
}
Expand Down