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

QHTTP modifies POST boundary #32

Open
HappySeaFox opened this issue Jan 13, 2017 · 4 comments
Open

QHTTP modifies POST boundary #32

HappySeaFox opened this issue Jan 13, 2017 · 4 comments

Comments

@HappySeaFox
Copy link

Hi. I use a great QHTTP library as a HTTP server implementation. When I receive a POST multipart/form-data request I get its boundary from the "content-type" header. However I noticed, that the HTTP header value is altered and is modified to be in a lower case (HTTP standard violation?). Because of that I cannot find the received boundary in a POSTed data.

@rv-17
Copy link

rv-17 commented Feb 14, 2017

Re: header fields: ”Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive.”

@HappySeaFox
Copy link
Author

Correct, field names are case-insensitive. But field values are not case-insensitive

@mrdeveloperdude
Copy link

mrdeveloperdude commented Feb 20, 2017

I was just going to file a report about this issue!

Long story short, to get it to work simply remove .toLower() for all header values in the qhttp code and it will work as expected (.toLower() on header key is fine as is).

And for you guys who don't understand the problem that is being addressed, here is an attempt to explain it:

When doing HTTP POST with "multipart/form-data" to upload a file with some parameters the client will prepare a header in the request like this:

Content-Type: multipart/form-data; boundary=SOME_RANDOM_STRING\r\n

The POST body will then contain the SOME_RANDOM_STRING between each data item as a means for the server to separate them into parts.

Any file uploads with all modern browsers will use this method.

As an example, the boundary string that Google Chrome generates when posting a file looks like this: "----WebKitFormBoundarySbQGNFBMdCG2vf0J". Notice that this boundary string contains mixed case data! If the header value is made toLower(), this boundary string will be useless, because the boundary string used to separate parts of the POST body will still be mixed case. I don't know if it is a standard violation or not, but it sure as hell breaks a pretty basic feature of HTTP POST- namely the use of boundaries to separate the fields of the uploaded data:-)

@kaedwen
Copy link

kaedwen commented Apr 9, 2020

stumbled over the same issue right now why is this not gonna be fixed? It's as simple as removing the toLower() and it does not break any convention.

Matching the boundary case insensitive might be a solution too.

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