zhongwencool / maxwell

Maxwell is an HTTP client which support for middleware and multiple adapters.
MIT License
111 stars 17 forks source link

Unable to include body with DELETE #64

Closed ijcd closed 6 years ago

ijcd commented 7 years ago

The HTTP spec does not forbid bodies on DELETE methods. In fact, I am working with a third-party API that requires it. I would like to use maxwell, but this is a showstopper at the moment. One, for example, allows DELETE on a collection to remove multiple elements (they are listed in the body) -- it is not strictly RESTful, but HTTP is not Rest, right?

Would you consider allowing this?

https://stackoverflow.com/questions/14323716/restful-alternatives-to-delete-request-body

Just need a change in builder.ex:

  @method_without_body [{:get!, :get}, {:head!, :head}, {:delete!, :delete}, {:trace!, :trace}, {:options!, :options}]
  @method_with_body [{:post!, :post}, {:put!, :put}, {:patch!, :patch}]
secretworry commented 7 years ago

@zhongwencool I think we should add support for this, but we may need more tests to ensure the DELETE with body works across all the supporting libs. For example, the hackney treats 'GET' and 'POST' separately when sending a binary as the body(here).

@ijcd A PR is warmly welcomed for the change:)