Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Add support for content type with charset #561

Merged

Conversation

Bmooij
Copy link
Contributor

@Bmooij Bmooij commented Jul 23, 2019

Add support for Content-Type with charset

Content-Type: text/html; charset=utf-8

It is ignoring the charset

@Bmooij Bmooij force-pushed the feature/Support_Content-Type_with_charset branch from 8e7dab2 to 022328d Compare July 23, 2019 21:30
@me-no-dev
Copy link
Owner

charset should be a separate variable :) it's not expected by the rest of the code to get such content type and some parsing may/will fail

@Bmooij
Copy link
Contributor Author

Bmooij commented Oct 2, 2019

I walked into this problem when writing a flutter app.
Remove charset from "Content-Type" header

According to RFCs and it seems the "parameter" part of the Content-Type value is either mandatory or optional depending on the particular MIME type/subtype:
https://tools.ietf.org/html/rfc2045#section-5

@@ -310,13 +310,11 @@ bool AsyncWebServerRequest::_parseReqHeader(){
if(name.equalsIgnoreCase("Host")){
_host = value;
} else if(name.equalsIgnoreCase("Content-Type")){
_contentType = value.substring(0, value.indexOf(';'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if there is no ';' in the value? A check should likely be made to assign the substring only if there is a ';' mark otherwise use the value as-is.

Copy link
Contributor Author

@Bmooij Bmooij Oct 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If value.indexOf returns -1 not found

value.substring returns the complete string

@Bmooij Bmooij force-pushed the feature/Support_Content-Type_with_charset branch from e41874b to 67640de Compare October 2, 2019 13:57
@me-no-dev me-no-dev merged commit 75acf88 into me-no-dev:master Oct 6, 2019
@Bmooij Bmooij deleted the feature/Support_Content-Type_with_charset branch October 15, 2019 08:27
DanielKnoop pushed a commit to DanielKnoop/ESPAsyncWebServer that referenced this pull request Jun 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants