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

Content Type of file uploaded in multipart/form-data request #271

Closed
myroslav opened this issue Nov 7, 2014 · 11 comments
Closed

Content Type of file uploaded in multipart/form-data request #271

myroslav opened this issue Nov 7, 2014 · 11 comments
Labels
bug Something isn't working enhancement New feature or enhancement

Comments

@myroslav
Copy link

myroslav commented Nov 7, 2014

curl support file Content-Type via following syntax:

curl --form "file=@page.pdf;type=application/pdf" http://httpbin.org/post
{
  "args": {}, 
  "data": "", 
  "files": {
    "file":
"data:application/pdf;base64,H4sICI0fXVQAA3BhZ2UucGRmAAvOz01VCE7MLchJVQhITE8FAAyOwbUQAAAA"
  }, 
  "form": {}, 
  "headers": {
    "Accept": "*/*", 
    "Connect-Time": "1", 
    "Connection": "close", 
    "Content-Length": "236", 
    "Content-Type": "multipart/form-data;
    boundary=------------------------7d87eceb5520850c", 
    "Host": "httpbin.org", 
    "Total-Route-Time": "0", 
    "User-Agent": "curl/7.32.0", 
    "Via": "1.1 vegur", 
    "X-Request-Id": "9f20c4bc-343b-4bc2-814d-9b2b9de75f83"
  }, 
  "json": null, 
  "origin": "213.130.19.243", 
  "url": "http://httpbin.org/post"
}

It look like the content it generates is something like:

POST /post HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=38516d25820c4a9aad05f1e42cb442f4
Host: httpbin.org

--38516d25820c4a9aad05f1e42cb442f4
Content-Disposition: form-data; name="file"; filename="page.pdf"
Content-Type: application/pdf
Content-Encoding: base64

H4sICI0fXVQAA3BhZ2UucGRmAAvOz01VCE7MLchJVQhITE8FAAyOwbUQAAAA
--38516d25820c4a9aad05f1e42cb442f4--

And I cannot achieve the same result in HTTPie. Any hints are appreciated.

@benjaminr
Copy link

Not sure exactly how close you need it to the original, but this might be a good starting point:

http -f http://httpbin.org/post file@page.pdf

@myroslav
Copy link
Author

I cannot make it provide Content-Type header inside the multipart/form-data container, and that is essential in our case.

@jkbrzt jkbrzt added bug Something isn't working enhancement New feature or enhancement labels Nov 12, 2014
@jkbrzt
Copy link
Member

jkbrzt commented Nov 12, 2014

@myroslav it's a bug/missing feature. Will look into that.

@jeltz
Copy link

jeltz commented Mar 2, 2015

Would it be possible to use a curl-like syntax with semicolon?

curl -F "web=@index.html;type=text/html" url.com 

@jkbrzt
Copy link
Member

jkbrzt commented Mar 2, 2015

@jeltz yes, good idea

@wodny
Copy link
Contributor

wodny commented Oct 24, 2015

Hi, I've pushed a refined version of PR #285 - PR #398 so it gets green light on TravisCI.

@cutz
Copy link

cutz commented Dec 2, 2015

@jkbrzt any update on getting #398 merged? I'd be willing to take a stab at a pull request to support specifying the type as part of the value if you are waiting on that.

@igr
Copy link

igr commented Dec 21, 2015

yeah, it would be cool if this thing can get in. do you know when?

@jocull
Copy link

jocull commented Jan 12, 2016

+1

1 similar comment
@lpellegr
Copy link

👍

jkbrzt added a commit that referenced this issue Feb 28, 2016
Closes #271 #285 #398

This adds filename-based detection. It's still not possible to specify the
content type manually, though.
@jkbrzt jkbrzt closed this as completed in 56f498c Feb 28, 2016
@eskatos
Copy link

eskatos commented Feb 28, 2016

🎉
Thanks!

rocketraman added a commit to rocketraman/spring-restdocs that referenced this issue Mar 7, 2016
NOTES:

* Httpie does not currently support setting the content type for each
  part in a multipart form -- these multipart types are currently
  ignored. See:

  httpie/cli#199
  httpie/cli#271
  httpie/cli#285
  httpie/cli#398

* There is an issue with specifying piped input for multipart form data.
  There is no way currently to specify the data without specifying a
  filename parameter in the Content-Disposition. For now, this is
  ignored. See:

  httpie/cli#342
rocketraman added a commit to rocketraman/spring-restdocs that referenced this issue Mar 7, 2016
NOTES:

* Httpie does not currently support setting the content type for each
  part in a multipart form -- these multipart types are currently
  ignored. See:

  httpie/cli#199
  httpie/cli#271
  httpie/cli#285
  httpie/cli#398

* There is an issue with specifying piped input for multipart form data.
  There is no way currently to specify the data without specifying a
  filename parameter in the Content-Disposition. For now, this is
  ignored. See:

  httpie/cli#342
rocketraman added a commit to rocketraman/spring-restdocs that referenced this issue Mar 7, 2016
NOTES:

* Httpie does not currently support setting the content type for each
  part in a multipart form -- these multipart types are currently
  ignored. See:

  httpie/cli#199
  httpie/cli#271
  httpie/cli#285
  httpie/cli#398

* There is an issue with specifying piped input for multipart form data.
  There is no way currently to specify the data without specifying a
  filename parameter in the Content-Disposition. For now, this is
  ignored. See:

  httpie/cli#342
rocketraman added a commit to rocketraman/spring-restdocs that referenced this issue Mar 7, 2016
NOTES:

* Httpie does not currently support setting the content type for each
  part in a multipart form -- these multipart types are currently
  ignored. See:

  httpie/cli#199
  httpie/cli#271
  httpie/cli#285
  httpie/cli#398

* There is an issue with specifying piped input for multipart form data.
  There is no way currently to specify the data without specifying a
  filename parameter in the Content-Disposition. For now, this is
  ignored. See:

  httpie/cli#342
wilkinsona pushed a commit to spring-projects/spring-restdocs that referenced this issue Mar 9, 2016
This commit adds support for generating a snippet that contains
the HTTPie command for the request. As the snippet does not require
any additional configuration, it has added to the existing default
snippets.

Httpie does not currently support setting the content type for each
part in a multipart form -- these multipart types are currently
ignored. See:

    httpie/cli#199
    httpie/cli#271
    httpie/cli#285
    httpie/cli#398

There is an issue with specifying piped input for multipart form
data. There is no way currently to specify the data without specifying
a filename parameter in the Content-Disposition. For now, this is
ignored. See:

    httpie/cli#342

See gh-207
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or enhancement
Projects
None yet
Development

No branches or pull requests

10 participants