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

Do not rfc3986 escape JSON bodies #1396

Merged
merged 2 commits into from Feb 2, 2015
Merged

Conversation

simov
Copy link
Member

@simov simov commented Feb 2, 2015

Example {json:{}} or {body:{}, json:true}
Related to #1315
Closes #1395

Also take a look at the options section of the documentation.

@nylen
Copy link
Member

nylen commented Feb 2, 2015

The behavior looks correct. I tried to clean up the test a little to get comfortable that we're doing the right thing here, can you pull in nylen@29f98f3?

@@ -1428,15 +1428,15 @@ Request.prototype.json = function (val) {
if (self.body !== undefined) {
if (!/^application\/x-www-form-urlencoded\b/.test(self.getHeader('content-type'))) {
self.body = safeStringify(self.body)
} else {
self.body = rfc3986(self.body)
Copy link
Member

Choose a reason for hiding this comment

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

Can you swap this conditional around? Also, I see we have a test for it (body + header + json) but in what situation is this needed?

edit - I think I see - this allows parsing a JSON response without sending the body as JSON.

@simov
Copy link
Member Author

simov commented Feb 2, 2015

Done. Are we good with this one (regarding your comment from above)?

nylen added a commit that referenced this pull request Feb 2, 2015
Do not rfc3986 escape JSON bodies
@nylen nylen merged commit 4475734 into request:master Feb 2, 2015
@nylen
Copy link
Member

nylen commented Feb 2, 2015

Yeah, thanks for taking a look!

@nylen
Copy link
Member

nylen commented Feb 2, 2015

version 2.53.0 released.

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.

JSON POST body URI encoded (RFC3986)
2 participants