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

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

Merged
merged 2 commits into from
Jul 10, 2017

Conversation

kelunik
Copy link
Contributor

@kelunik kelunik commented Jul 10, 2017

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets Fixes #18, #28.
License MIT

What's in this PR?

As no body is allowed, the content-length header is optional.

Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

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

i'd rather not add fake data that whe then assert on, that feels strange.

@@ -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 :-)

Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

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

looks good to me. thanks @kelunik !

@Nyholm
Copy link
Member

Nyholm commented Jul 10, 2017

All tests passes. Thank you!

@Nyholm Nyholm merged commit ca59f01 into php-http:master Jul 10, 2017
@kelunik kelunik deleted the fix-trace-content-length branch July 10, 2017 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tests for TRACE requests should not send/expect body
3 participants