8000 Symfony Response on 416 HTTP Exception · Issue #13465 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Symfony Response on 416 HTTP Exception #13465

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

Closed
DmitryKmita opened this issue Jan 20, 2015 · 6 comments
Closed

Symfony Response on 416 HTTP Exception #13465

DmitryKmita opened this issue Jan 20, 2015 · 6 comments

Comments

@DmitryKmita
Copy link

Version of symfony: 2.6.3
Version of cUrl: 7.19.7

If I send a request to an action that throws 416 Exception the curl body is empty.
In ~2.5 version of the symfony there was no such problem.

Because of this problem if you have a test that validates the error page and uses cUrl to parse the DOM- it will get an error "The current node list is empty".

By specs in 416 HTTP error response should have:
Content-Range header.
I compared the response between ~2.5 version and 2.6.3 and found that in 2.6.3 I don't get
Transfer-Encoding: chunked header, maybe this is the reason why response body is empty.

@jaytaph
Copy link
Contributor
jaytaph commented Jan 21, 2015

There was recently a patch that dealt with adding an invalid Content-Range header on non-safe request (like POST, PUT etc).

Are you fetching the page through a GET request?

@jakzal
Copy link
Contributor
jakzal commented Jan 21, 2015

@DmitryKmita would you mind to provide code to reproduce your issue?

8000

@DmitryKmita
Copy link
Author

This is a GET request.
Code in symfony action:

throw new HttpException(416, "some message");

and make simple CURL request from CLI to this action:

curl -X GET '%URL%' -v

@jaytaph
Copy link
Contributor
jaytaph commented Jan 22, 2015

By specs in 416 HTTP error response should have: Content-Range header.

Not quite, the spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) says that a Content-Range SHOULD be added when a range-request has been made (ie: when you have specified something like: Content-Range: bytes 10-20 in your request). Basically telling it: i could not satisfy returning a response for bytes 10-20.

If you did not specify a content-range, but added an Accept-Range: meters, where meters is a range-format you want to use (http://tools.ietf.org/html/rfc7233#section-2.2), or you just add `Accept-Range: bytes), and you don't support ranged responses, then you can send a 416 back without a content-range, telling the client that you are not able to return a ranged response in the requested format.

Transfer-encoding: Chunked has nothing to do with ranges, it's just that the response output is of indefinite size (like passing output from a shell command, or database rows), so it will not send a content-length header. It will keep on pushing response data and return an empty chunk at the end, marking the end of the response.

I can check to see if I can reproduce this on both Symfony versions though.

@jakzal
Copy link
Contributor
jakzal commented Mar 11, 2016

By specs in 416 HTTP error response should have: Content-Range header.

This has been recently fixed by #18080

@jakzal
Copy link
Contributor
jakzal commented Mar 11, 2016

Closing as I can't reproduce getting an empty response when throwing the HttpException (neither on 2.3 nor 2.7). In dev environment an exception page is shown, while in prod the standard error page.

@jakzal jakzal closed this as completed Mar 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0