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

Support empty POST requests #16

Closed
josephmturner opened this issue Jan 17, 2023 · 6 comments
Closed

Support empty POST requests #16

josephmturner opened this issue Jan 17, 2023 · 6 comments
Labels
enhancement New feature or request
Milestone

Comments

@josephmturner
Copy link
Contributor

Would you support sending POST requests with no body?

@alphapapa
Copy link
Owner

If that's needed, sure, why not. :)

@alphapapa alphapapa added the enhancement New feature or request label Jan 20, 2023
@alphapapa alphapapa added this to the 0.4 milestone Jan 20, 2023
@josephmturner
Copy link
Contributor Author

It's not that important. I have a use-case for sending a POST request with no body, and

(plz 'post url
  :as 'response)

looks cleaner than

(plz 'post url
  :body ""
  :as 'response)

If allowing empty POST requests adds unnecessary complexity to plz.el, let's not do it.

@alphapapa
Copy link
Owner

Well, it's mostly a matter of deleting one line of code, an assertion that signals an error if the body is not specified, and then specifying a default empty string for the body. So it's not a big deal on the code side.

My concern is about making the API clear for the user. I added the assertion because it seems like it would generally be an oversight if the user made a POST or PUT request without a body, and signaling the error before sending the request seems more helpful than making the request and having the user potentially be confused by the response from the server.

I don't have strong feelings about this either way. I suppose I'd default to the status quo and letting the user give the empty string argument.

What do you think? Thanks.

@Dima-369
Copy link

Dima-369 commented Feb 5, 2023

What do you think?

I also have use-cases for using methods like POST and PUT without a request body and I would highly prefer this:

(plz 'post url
  :as 'response)

and signaling the error before sending the request seems more helpful than making the request and having the user potentially be confused by the response from the server.

Well, you can turn this argument either way.
Adding :body "" confuses me more (but once you know this, it's kind of fine) because it is not required for 'get or the others.

@alphapapa
Copy link
Owner

@Dima-369 Ok, that's good enough for me to make this change. Thanks for your feedback.

@josephmturner
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants