Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

can you support parse http multipart header #486

Closed
hongjiangchen opened this issue Jul 4, 2019 · 9 comments
Closed

can you support parse http multipart header #486

hongjiangchen opened this issue Jul 4, 2019 · 9 comments

Comments

@hongjiangchen
Copy link

for example,when we upload a file through http post, http_parse can not parse multipart header

@indutny
Copy link
Member

indutny commented Jul 4, 2019

Do you have an example of such request? We've been using this parser in Node.js for quite some time. As far as I know multipart headers should be well supported.

@hongjiangchen
Copy link
Author

Do you have an example of such request? We've been using this parser in Node.js for quite some time. As far as I know multipart headers should be well supported.

upload_file.zip
here is the pcap

@indutny
Copy link
Member

indutny commented Jul 4, 2019

Since this library does no networking, could you please extract the actual request from pcap file and put into gist or something?

Thanks!

@hongjiangchen
Copy link
Author

POST /fileupload/servlet/UploadHandleServlet HTTP/1.1
Host: 192.168.57.14:8080
Connection: keep-alive
Content-Length: 449
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Origin: http://192.168.57.14:8080
User-Agent: Mozilla/5.0 (Windows NT 5.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryAe47vGj7ybAe6RwO
Referer: http://192.168.57.14:8080/fileupload/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8
Cookie: JSESSIONID=969AC5FBD069EE6218EB10513726B244; JSESSIONID=400CC78DF5784F303702CC7F02C6122C

------WebKitFormBoundaryAe47vGj7ybAe6RwO
Content-Disposition: form-data; name="username"

------WebKitFormBoundaryAe47vGj7ybAe6RwO
Content-Disposition: form-data; name="file1"; filename="123.doc(5).exe"
Content-Type: application/x-msdownload

123456
------WebKitFormBoundaryAe47vGj7ybAe6RwO
Content-Disposition: form-data; name="file2"; filename=""
Content-Type: application/octet-stream

------WebKitFormBoundaryAe47vGj7ybAe6RwO--

@hongjiangchen
Copy link
Author

hongjiangchen commented Jul 5, 2019

content-disposition and Content-Type can not be parsed

@indutny
Copy link
Member

indutny commented Jul 5, 2019

They should be emitted as body of request (which they are). Is that what you see?

@hongjiangchen
Copy link
Author

yes, they are emitted as body of request,and we can parse the ones above the ‘------WebKitFormBoundaryAe47vGj7ybAe6RwO’ . we also need parse content-disposition and more from MIME header

@indutny
Copy link
Member

indutny commented Jul 5, 2019

I see now. Thank you for clarification.

Unfortunately, this is working as intended. It would not be reasonable to solve this on http-parser level. Rather the high-level user of this library should be solving it.

Sorry!

@indutny indutny closed this as completed Jul 5, 2019
@andrew-aladev
Copy link

@hongjiangchen, libebb authors just forget to implement it. This is reasonable to be solved on http parser level, because boundary rfc7578 is http related thing. You can find this code, just google "multipart http parser". But it requires complete source code changes.

Nodejs here only "maintains" (almost abandoned) parser and do not care about any new features. Nodejs itself have a higher level multipart form data parser, so I am sure that multipart support won't ever be a part of new bicycle named "llhttp".

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

No branches or pull requests

3 participants