-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[BrowserKit] HttpBrowser ignores GET-request body #37609
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
Comments
Well, BrowserKit is meant to emulate browsers. And AFAIK, no browser is allowing to include a body in a GET request. |
I guess that makes sense. Is there a standardised way to do functional tests on an API? Or could/should the |
How does API Platform do? /cc @dunglas |
Hi @Jeroeny . Interesting to notice that RFC-7231 obsolets RFC-2616.
Which for me shows that your API implementation can define it's own semantics. RFC-2616 section 4.3
RFC-2616 section 9.3
After all that, I'd suggest that, instead of this being a bug, perhaps we could suggest a way to tell BrowserKit to process the message-body on a GET request |
@thiagomp Thanks for the thorough feedback. Explicitly telling BrowserKit about a message payload sounds good too. In that case I'd probably go with
|
@Jeroeny Do you want to take a look in the PR I've created? symfony/browser-kit#11 |
@thiagomp Yes something like that would be nice 👍. |
…tent-type (thiagomp) This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- [BrowserKit] Allowing body content from GET with a content-type | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #37609 | License | MIT | Doc PR | N/A This allows a GET request to sent a payload if it specifies a content-type in the HTTP header as per our conversation in the ticket. Commits ------- 93c2f5e [BrowserKit] Allowing body content from GET with a content-type
Symfony version(s) affected: >=4.3
Description
When using the BrowserKit to do functional tests, I've been trying to use the HttpBrowser to perform requests. Our API uses the request body to send data as JSON. The KernelBrowser doesn't seem to mind this and passes on the request to the kernel without modification. However, the HttpBrowser 'extracts' the body and does an early-return when the method is GET. This doesn't seem to comply with the RFC. And makes the use for HttpBrowser not possible for us.
How to reproduce
This is where it's filtered out: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/BrowserKit/HttpBrowser.php#L64
Possible Solution
Remove
GET
from thein_array
check to allow bodies for GET-requests.If that's agreed upon I'd gladly make a PR.
The text was updated successfully, but these errors were encountered: