Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign up[fix] Allowing raw request body when Content-Type is already specified #60
Conversation
brblck
changed the title
[fix] allowing raw request body when content-type is already specified
[fix] Allowing raw request body when Content-Type is already specified
Jun 6, 2015
This comment has been minimized.
This comment has been minimized.
|
Would you mind adding a test for this? |
This comment has been minimized.
This comment has been minimized.
|
@sferik done. apologies for not including that from the get go. |
This comment has been minimized.
This comment has been minimized.
|
No need to apologize. Thanks for the patch! |
added a commit
that referenced
this pull request
Jun 8, 2015
sferik
merged commit 9faa220
into
twitter:master
Jun 8, 2015
1 check passed
This comment has been minimized.
This comment has been minimized.
|
Just my own guilt ;-) Thanks Erik. |
brblck
deleted the
brblck:post_body_fix
branch
Jun 16, 2015
This comment has been minimized.
This comment has been minimized.
|
@sferik got a few people asking when this fix will be released. Ads API in particular has a new feature launching this week which twurl won't work with unless this fix is present. Do you have an ETA on when we'll be cutting a new gem? I hate to ask for a release just for this, but I also don't see much else in motion on here at the moment. |
This comment has been minimized.
This comment has been minimized.
|
@sferik Ping. |
This comment has been minimized.
This comment has been minimized.
|
Hey. Thanks for the ping. I was on vacation last week. I’ll try to get to this later today. I’ll also add you as a gem owner so you can push releases yourself in the future. |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Thanks a bunch @sferik! |
brblck commentedJun 6, 2015
Currently, when you use the
-doption twurl callsrequest.set_form_datawhich URL encodes the request body and overrides any previously setContent-Typevalue by forcibly setting it toapplication/x-www-form-urlencoded.https://github.com/twitter/twurl/blob/master/lib/twurl/oauth_client.rb#L112
Example without Modification (Unexpected Behavior):
This behavior prevents users from ever being able to send a request with
Content-Type: application/jsonand a JSON payload in the request body.The change I'm making here is simple, non-breaking and preserves the default behavior while allowing the expected behavior you'd see in curl for the scenario described. If the request has
Content-Typeset to any value, we setrequest.bodyto the raw value ofoptions.dataand leave the content header untouched.Example with Modification (Expected Behavior):