简体   繁体   中英

Python http server: handle POST application/octet-stream

I have a very basic webserver working with BaseHTTPServer. I can handle simple GET and POST requests (even multipart/form-data), but I am having trouble handling "application/octet-stream". Any hints?

The cgi module's form parser is meant only for multipart/form-data .

Single part forms - meaning anything with a standard MIME type in self.headers.getheader('content-type') - are available to you as the normal binary data via self.rfile - no need to parse them.

Take a look here:

Furthermore, don't be confused by that cgi stuff. It appears to be antiquated naming convention from the old days (pre Ruby-on-Rails) when cgi was common and web frameworks were unheard of.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM