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 #9

Open
gbrlsnchs opened this issue Apr 7, 2021 · 3 comments
Open

Support multipart/form-data #9

gbrlsnchs opened this issue Apr 7, 2021 · 3 comments

Comments

@gbrlsnchs
Copy link

Does this plugin only accept JSON requests? This was not clear in docs, and I also wasn't able to do form-data requests.

@nicwest
Copy link
Owner

nicwest commented May 24, 2021

Good question!

In theory yes, if curl supports it then the plugin should support it.

It would look something like this:

POST http://httpbin.org/post HTTP/1.1
Host: httpbin.org
Content-Type: multipart/form-data;boundary="boundary"
Content-Length: 174

--boundary
Content-Disposition: form-data; name="field1"

value1
--boundary
Content-Disposition: form-data; name="field2"; filename="example.txt"

value2
--boundary--


HTTP/1.1 200 OK
Date: Mon, 24 May 2021 11:51:12 GMT
Content-Type: application/json
Content-Length: 463
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

{
  "args": {}, 
  "data": "", 
  "files": {
    "field2": "value2"
  }, 
  "form": {
    "field1": "value1"
  }, 
  "headers": {
    "Accept": "*/*", 
    "Content-Length": "174", 
    "Content-Type": "multipart/form-data;boundary=boundary", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/7.68.0", 
    "X-Amzn-Trace-Id": "Root=1-60ab9330-6da5fc59153f7d211345873c"
  }, 
  "json": null, 
  "origin": "79.173.133.167", 
  "url": "http://httpbin.org/post"
}

Some boundary defining helper methods might be helpful.

@sebiwi
Copy link

sebiwi commented Feb 22, 2024

@nicwest is it possible to include files in the form using vim-http?

@nicwest
Copy link
Owner

nicwest commented Feb 22, 2024

@sebiwi at the moment it would only work if you copy the body of the text over into a boundary similar to the above example.

If someone can come up with a sensible way in-lining files I'm more than happy to merge that.

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

3 participants