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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/WebRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,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

if (value.startsWith("multipart/")){
_boundary = value.substring(value.indexOf('=')+1);
_boundary.replace("\"","");
_contentType = value.substring(0, value.indexOf(';'));
_isMultipart = true;
} else {
_contentType = value;
}
} else if(name.equalsIgnoreCase("Content-Length")){
_contentLength = atoi(value.c_str());
Expand Down