-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Move ContentType text into flash and revise functions #1460
Conversation
mikee47
commented
Oct 5, 2018
- fromFileExtension() and fromFullFileName() return String instead of const char*
- Code moved into new file, WebConstants.cpp
- Bugfix: File extension matching is now done on entire extension, not just the start; this caused a mis-interpretation of 'json' as 'js'.
- MIME_TYPE_MAP performs a 1:1 mapping between file extension and MIME type. For HTML files the extension has been changed to .html as this appears to be the generally preferred format. The alternative, .htm, is checked in the code when mapping to MIME type.
- toString() returns an invalid String so the caller can use if() to check for validity. The function previously returned "", which is a rather strange string to be embedding in an HTML header.
* fromFileExtension() and fromFullFileName() return String instead of const char* * Code moved into new file, WebConstants.cpp * Bugfix: File extension matching is now done on entire extension, not just the start; this caused a mis-interpretation of 'json' as 'js'. * MIME_TYPE_MAP performs a 1:1 mapping between file extension and MIME type. For HTML files the extension has been changed to .html as this appears to be the generally preferred format. The alternative, .htm, is checked in the code when mapping to MIME type. * toString() returns an invalid String so the caller can use if() to check for validity. The function previously returned "<unknown>", which is a rather strange string to be embedding in an HTML header.
@mikee47 What is your non-mforce-l32 compiler saying about the free heap improvements? |
Going by the travis builds, and using the HttpServer_WebSockets sample, free RAM goes from 49239 to 49507 for this PR. |
For the past few PRs we have free RAM / IRAM as: The uri-escaping result is weird; goes down then goes back up again afterwards! Update: I discovered the reason is my dodgy patching of http_parser.c. I managed to remove the PROGMEM_L32 attribute on tokens[] (line 195), but the next PR replaced it with PROGMEM. |
Yes, I saw that one but did not bother you because the next PR was already suggesting proper fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming issues.
if(!fileName) | ||
return nullptr; | ||
|
||
const char* pExt = strrchr(fileName, '.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just rename the variable to extension
. Try to use more descriptive names. I guess p
is a prefix for "pointer" but try to avoid it.
return mimestr_HTML; | ||
|
||
for(unsigned i = 0; i < ARRAY_SIZE(extStrings); ++i) { | ||
if(*extStrings[i] == extension) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More descriptive name, please.