Format option for setting Content-Type #109

Merged
merged 2 commits into from Jul 18, 2012

Projects

None yet

2 participants

@dmarkow
Member
dmarkow commented Jul 18, 2012

From the discussion in #108, this adds support for a format parameter, and sets reasonable default content types when neither a content type nor a format is provided.

For now, the format parameter is only used to decide on a Content-Type header. However, it could be used in the future to set accept headers, automatically manipulate payloads (e.g. format: :json might result in the payload being converted to a JSON string before sending), etc.

Formats provided are:

  • text (text/plain)
  • json (application/json)
  • xml (application/xml)
  • form_data (multipart/form-data)
  • form_encoded (application/x-www-form-urlencoded)

When a format is not provided, the default is form_encoded. However, if there is a hash-based payload or files to upload, it defaults to form_data instead.

Contributor

Awesome. I'm going to have to bump the version and release a gem. I'd like to also give you commit access and welcome you to the team!

@mattetti mattetti merged commit a791b2c into rubymotion:master Jul 18, 2012
Member
dmarkow commented Jul 19, 2012

Great, thanks for the access!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment