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 multipart/form-data POST requests #22

Open
josephmturner opened this issue Feb 23, 2023 · 4 comments
Open

Support multipart/form-data POST requests #22

josephmturner opened this issue Feb 23, 2023 · 4 comments

Comments

@josephmturner
Copy link
Contributor

According to this SO post, multipart/form-data POST requests can be accomplished using curl like so:

curl -v -F key1=value1 -F upload=@localfilename URL
@alphapapa
Copy link
Owner

#4 shows an example of this also.

@astoff
Copy link

astoff commented Oct 4, 2023

Appending things to plz-curl-default-args seems not to work very well. For example, the code below gives curl error 2 (Failed to initialize). The reason seems to be that the @- argument which is also added in this case is incompatible with -F.

(let* ((plz-curl-default-args
        `("-F" "file=@/some/existing/file"
          ,@plz-curl-default-args)))
  (plz 'post "https://httpbin.org/post"))

I think one could come up with a reasonable :body notation for form submissions along the lines of

(form (name "first-part" file "file1.txt" type "text/plain") 
      (name "second-part" body "some <i>text<i> in my form" type "text/html"))

@alphapapa
Copy link
Owner

Yeah, I didn't mean for users to modify the default args in order to send form data. :)

As for the body: I'll need to take another look at the spec to see how that works. It might be possible to send a form-data part and a non-form-data part, in which case using :body might be inappropriate. But anyway, specifying the form data could probably be done with one or more alists (or even just any map type using the map library).

@cinsk
Copy link

cinsk commented Oct 10, 2023

Yes, I really want to get the form support, especially to upload file without reading to Emacs buffer with some additional text parameters. It would be very helpful if @astoff 's suggestion can be implemented.

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

No branches or pull requests

4 participants