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

Content type startswith #1084

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

devel0
Copy link

@devel0 devel0 commented Nov 4, 2021

allow canHandle not to discard request such as

Content-type: application/json; charset=utf-8

without this patch only valid request for AsyncCallbackJsonWebHandler are

Content-type: application/json

@Domochip
Copy link

Hi, I've just encountered this issue.
My solution is a bit different.
I replaced :
if ( !request->contentType().equalsIgnoreCase(JSON_MIMETYPE) )
by :
if ( !request->contentType().substring(0, strlen(JSON_MIMETYPE)).equalsIgnoreCase(JSON_MIMETYPE) )

Simpler to read but create a little heap consumption.
What's your mind about it?

@devel0
Copy link
Author

devel0 commented Dec 30, 2021

@Domochip I agree, your solution is simpler to read, while mine was designed to work with existing string.

Actually I see this PR isn't yet merged so you could make another PR mentioning this one in your message so that when one of the two will accepted the other could discarded.

Thanks for your suggestion.

@RayPS
Copy link

RayPS commented Mar 10, 2022

Just encountered the same issue, given 500 error with no any clue or error message, spent lot of hours debugging this library until I found this line:

if ( !request->contentType().equalsIgnoreCase(JSON_MIMETYPE) )

nthd added a commit to nthd/ESPAsyncWebServer that referenced this pull request Oct 16, 2023
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

Successfully merging this pull request may close these issues.

3 participants