wrecker icon indicating copy to clipboard operation
wrecker copied to clipboard

Add function to set ContentType at request level

Open BrandonRomano opened this issue 9 years ago • 3 comments

Realized in #14 we should probably add this.

Probably ContentType would be a good function name for this.

  • [ ] Create Function
  • [ ] Determine appropriate content type to select in sendRequest (Explicit value set with ContentType would always be picked over the calculated ones)
  • [ ] Update Tests
  • [ ] Add a comment in the README

BrandonRomano avatar Jun 23 '15 03:06 BrandonRomano

I think Wrecker should be able to determine the default content type based on the parameters that have been included. For example, if there's a BODY, then set the Content-Type to "application/json". Otherwise, set it to "x-www-form-encoded". Then, this could be overridden by the new function .ContentType()

Once we get to executing the request, we can switch on the Content-Type to choose the encoder (Form, JSON, or XML)

EDIT: This means that we could probably remove the DefaultContentType property on the Wrecker object. It should be simple enough to determine that from the properties of each request.

benpate avatar Jun 25 '15 19:06 benpate

Okay, yeah I agree... Let's do that!

BrandonRomano avatar Jun 26 '15 14:06 BrandonRomano

Hey @benpate I've updated this issue's description to match what we want to do with this now.

BrandonRomano avatar Jul 02 '15 20:07 BrandonRomano