Skip to content

Create a test that shows bug #1403#1407

Open
ciaoben wants to merge 1 commit into
ruby-grape:masterfrom
ciaoben:test_bug_#1403
Open

Create a test that shows bug #1403#1407
ciaoben wants to merge 1 commit into
ruby-grape:masterfrom
ciaoben:test_bug_#1403

Conversation

@ciaoben

@ciaoben ciaoben commented May 26, 2016

Copy link
Copy Markdown

I have created an example that shows that even if it is setted format :json, if I send a post request with content_type: application/x-www-form-urlencoded it does return 201

I have created an example that shows that even if it is setted `format :json`, if I send a post request with content_type: application/x-www-form-urlencoded it does return `201`
@dblock

dblock commented May 26, 2016

Copy link
Copy Markdown
Member

Isn't this what the doc says? "it will not parse any other input than ... application/x-www-form-urlencoded"?

The formats apply to parsing, too. The following API will only respond to the JSON content-type and will not parse any other input than application/json, application/x-www-form-urlencoded, multipart/form-data, multipart/related and multipart/mixed. All other requests will fail with an HTTP 406 error code.

@ciaoben

ciaoben commented May 26, 2016

Copy link
Copy Markdown
Author

Ok, I definitely need a vacation. I have read this sentence hundred times, and all the time I misunderstand it.

My bad, sorry this time waste!

@ciaoben ciaoben closed this May 26, 2016
@dblock

dblock commented May 26, 2016

Copy link
Copy Markdown
Member

It's not obvious that it's supposed to behave this way, I think the biggest reason is simply that Rack does some of the parsing and we can't force it not to.

@dblock

dblock commented May 26, 2016

Copy link
Copy Markdown
Member

I would be curious to see what a PR "fixing" this looks like, and would like to open it for discussion. I'm going to reopen this.

@dblock dblock reopened this May 26, 2016
@ciaoben

ciaoben commented May 26, 2016

Copy link
Copy Markdown
Author

Do you mean introducing the case that if using format :json, it actually accept ONLY json?

I am not familiar with your codebase, but if you said that if it is due to some Rack level parsing, I can only imaging creating some sort of "extension" in the form of a Rack middleware.

@dblock

dblock commented May 26, 2016

Copy link
Copy Markdown
Member

Right, I mean treating this as a bug and fixing it.

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.

2 participants