The boundary parsing in the webserver could end up missing boundaries if the
uploaded file had `--` at the start of the line because it read in the entire boundary
length worth of bytes. Fix by only reading up to either the boundary length or
a newline, avoiding the issue.
Fixes#7542
* webhook api
* simplify webserver debug printouts, move text to flash
* Hook examples in HelloServer example
* print executable code address in example
* simplify example per @mcspr suggestion
* WebServer: Allow client to send many requests on the same connection
* WebServer: Keep the connection alive with a client by default
* WebServer: Use the request's HTTP version and Connection header to set the default keep alive value
* Fix a typo in a comment
* New Graph Example
* Now using isFlashInterfacePin() no define default GPIO mask.
* Added info about zooming.
* Adressed requested changes (boolean > bool,
using esp8266::polledTimeout::periodicMs, reducing complexity)
* Flash size reduction for mime-type
* moving from fixed size strings to standard PROGMEM strings
* adding `#define MIMETYPE_MINIMAL` to reduce the footprint to
mime-types that are strictly necessary
* Added MIMETYPE_MINIMAL conditionals
* Server Sent Events example - issue #7008
Illustrates the use of SSE using ESP8266WebServer
* Update ServerSentEvents.ino
* Create ServerSentEventsMultiClient.ino
* sync
* Update ServerSentEvents.ino
* Update ServerSentEvents.ino
Fix missing variables in printf statments
Fix subscriptioncount not decreasing
Fix SSEBroadcastState (argument sequence wrong)
* Undo the library additions, move to current master
* Fix compiler warning
* Address review and fix multi-sensor updates
Address points of @devyte's code review:
* Use IPAddress vs. uint32_t
* Refactor the URL parsing logic to use strlen vs. sizeof, since there
was some confusion in the original (correct) version
* Minimize copies of WiFiClients while in use
* Use byref access for sensor updates
Fix multi-sensor updates
* Create an update Ticker for each sensor, because the original code
only had one whose callback was overridden by sensorB, meaning sensorA
never changed
* Fix IPv6 build errors
* Remove WiFiClient extraneous copy
Avoid duplicating WiFiClient by using the WiFiClient object embedded in
the subscriber[] array instead.
Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
* Deprecate SPIFFS, move examples to LittleFS
SPIFFS has been a great filesystem, but it has significant problems in
many cases (and it's also pretty slow). Development seems to have
slowed/stopped on the upstream version, and we're not able to provide
support or fix the known issues with it as-is.
Deprecate SPIFFS variable.
Update all examples to use LittleFS instead of SPIFFS.
Also, minor cleanup on very old examples which has obsolete delays
waiting for the Serial port to come up, or which were stuck at 9600 baud
because of their ancient AVR heritage.
Fixes#7095
* Remove leftover debug code
* Clean up comments in some examples
* Update documentation on SPIFFS deprecation
* Fix host tests to avoid deprecation warnings
* Fix cut-n-paste error
* Restore SpeedTest.ino, adjust to allow custom FSes
Co-authored-by: Develo <deveyes@gmail.com>
* Refactored to make getContentType public for 3rd party use.
* Added missing "jpeg" extension
* Use getContentType() from mime namespace.
* Also add .jpeg extension
* Minimal file with a few ESP8266-specific keywords - github issue #3701
* Renamed "SDWebServer" to the more universal "WebFileManager"
* SD was replaced by SDFS, and sketch now works on either SDFS, SPIFFS or
LittleFS based on a #define logic (required adding a second param to open() and
replacing 'FILE_WRITE' by "w") + Added size information to file list and a /status request handler to return filesystem status
* Tree panel width is now proportional to window. Changed icons (lighter and
more neutral), including one for files. Show size of files. Fill
"filename" box upon clicking on a file. Sort files alphabetically.
* Replaced by a lighter version
* Return the filesystem time in the status object
+ Massive cleanup/merge/align with some code from the FSBrowser example
and misc refactorings
* Fixed folder handling
* Replaced the FILESYSTEM #define by a filesystem variable, and introduced FSConfig to prevent FS formating.
Fixed recursive deletion.
Got rid of specific isDir() for SPIFFS.
* Made 8.3 lowercase filenames formating optional (disabled by default).
Refresh only part of the tree when possible.
Selecting a file for upload defaults to the same folder as the last
clicked file.
Removed the Mkdir button on SPIFFS.
* Added 'wait' cursor during asynchronous operations.
Slight refactoring of XMLHttpRequest completion handling
* Removed limitation "files must have an extension, folders may not".
Case insensivity of the extension for the editor and preview.
* Support Filenames without extension, Dirnames with extension.
Added Save/Discard/Help buttons to Editor, discard confirmation on leave, and refresh tree/status upon save.
Removed redundant Ctrl-Z + Ctrl-Shift-Z shortcut declarations.
Small bug fixes.
+ some refactoring
* Fixed tree refresh on delete in all cases by returning the remaining path as response to the delete request.
Refactoring
* Changed FS status in text by a percentage graph, with numbers as tooltip.
Unsupported files on SPIFFS (files at root not sarting with "/", files with double "/", files ending with "/") are now detected and reported in the page.
* Small fix + refactoring
* Restrict filename support check to SPIFFS.
* Implemented Move/Rename.
Added "loading" screen during async operations (dim with spinner and status).
Fixed "discard" feature that kept prompting even after an image was loaded.
Improved refresh of parts of the tree, with recursive listing.
Moved the "path" id attribute to the "li" elements for folders (was already the case for files).
Refactoring and cleanup.
* Fixed broken spinner
* Cosmetic improvements.
Removed non-functional Upload context menu.
Fixed error in response to move requests.
Added minified version.
* Added specific icons for text and image files.
Fixed incompatibilities with SPIFFS.
Fixed a race condition between deletion and reinsertion of nodes when multiple folders are refreshed.
Fixed missing URL decoding for files with special chars (e.g. space char).
Moved info from source code comment to a readme.md file.
Added source PNG to git.
Cleanup.
* Added favicon.ico.
* Renamed project
* Small changes
* Add a note about the ace.js dependency
* Minor changes
* Define LittleFS by default.
If both uncompressed and gz versions exist, use uncompressed version.
Small fixes.
* Define LittleFS by default.
If both uncompressed and gz versions exist, use uncompressed version.
Small fixes.
* Restyled version
* (dummy edit to retrigger broken CI)
* Using unsigned int for comparison with String.length()
* Return an error when upload fails (e.g. filesystem full)
* Trying to reorder functions to please CI
* Reordered functions to please CI.
* Moved file
* Renamed "SDWebServer" to the more universal "WebFileManager"
* SD was replaced by SDFS, and sketch now works on either SDFS, SPIFFS or
LittleFS based on a #define logic (required adding a second param to open() and
replacing 'FILE_WRITE' by "w") + Added size information to file list and a /status request handler to return filesystem status
* Tree panel width is now proportional to window. Changed icons (lighter and
more neutral), including one for files. Show size of files. Fill
"filename" box upon clicking on a file. Sort files alphabetically.
* Replaced by a lighter version
* Return the filesystem time in the status object
+ Massive cleanup/merge/align with some code from the FSBrowser example
and misc refactorings
* Fixed folder handling
* Replaced the FILESYSTEM #define by a filesystem variable, and introduced FSConfig to prevent FS formating.
Fixed recursive deletion.
Got rid of specific isDir() for SPIFFS.
* Made 8.3 lowercase filenames formating optional (disabled by default).
Refresh only part of the tree when possible.
Selecting a file for upload defaults to the same folder as the last
clicked file.
Removed the Mkdir button on SPIFFS.
* Added 'wait' cursor during asynchronous operations.
Slight refactoring of XMLHttpRequest completion handling
* Removed limitation "files must have an extension, folders may not".
Case insensivity of the extension for the editor and preview.
* Support Filenames without extension, Dirnames with extension.
Added Save/Discard/Help buttons to Editor, discard confirmation on leave, and refresh tree/status upon save.
Removed redundant Ctrl-Z + Ctrl-Shift-Z shortcut declarations.
Small bug fixes.
+ some refactoring
* Fixed tree refresh on delete in all cases by returning the remaining path as response to the delete request.
Refactoring
* Changed FS status in text by a percentage graph, with numbers as tooltip.
Unsupported files on SPIFFS (files at root not sarting with "/", files with double "/", files ending with "/") are now detected and reported in the page.
* Small fix + refactoring
* Restrict filename support check to SPIFFS.
* Implemented Move/Rename.
Added "loading" screen during async operations (dim with spinner and status).
Fixed "discard" feature that kept prompting even after an image was loaded.
Improved refresh of parts of the tree, with recursive listing.
Moved the "path" id attribute to the "li" elements for folders (was already the case for files).
Refactoring and cleanup.
* Fixed broken spinner
* Cosmetic improvements.
Removed non-functional Upload context menu.
Fixed error in response to move requests.
Added minified version.
* Added specific icons for text and image files.
Fixed incompatibilities with SPIFFS.
Fixed a race condition between deletion and reinsertion of nodes when multiple folders are refreshed.
Fixed missing URL decoding for files with special chars (e.g. space char).
Moved info from source code comment to a readme.md file.
Added source PNG to git.
Cleanup.
* Added favicon.ico.
* Renamed project
* Small changes
* Add a note about the ace.js dependency
* Minor changes
* Define LittleFS by default.
If both uncompressed and gz versions exist, use uncompressed version.
Small fixes.
* Define LittleFS by default.
If both uncompressed and gz versions exist, use uncompressed version.
Small fixes.
* Restyled version
* (dummy edit to retrigger broken CI)
* Using unsigned int for comparison with String.length()
* Return an error when upload fails (e.g. filesystem full)
* Trying to reorder functions to please CI
* Reordered functions to please CI.
* Update to use chunked response API
* Removed temp files commited by mistake
* Avoid using args() as requested
* Use html entity for non-breaking space to avoid losing char when minifying
* Script to preprocess index.htm
* (reformated code)
* (comments)
* Preprocessed files
* Fixed dump to create an actual include file
* Optionally embed index.htm in code.
(+ documentation and preprocessing script)
* (reformated)
* If editor cannot be loaded from the web, try a local version, or default
to a text viewer if not present
* (removed a TODO item :-))
* (forgot to reprocess files after last commit)
* (reprocess should be ok this time)
* Return error 500 when upload fails immediately (e.g. filesystem full)
* Use standard <meter> tag for filesystem use
* (updated following changes to index.htm)
* Do not include gzipped version in the data folder by default. Leave it in the extras folder and change readme accordingly (plus some reformatingi of the readme file)
* Gzipped index file not included in data/edit by default. It is now left in the extras folder.
Readme file was updated accordingly (+ some reformating)
* Reduce String clutter by reserving and concatenating elements one by one.
* Use clear() to reset String.
* Avoid comparisons against empty String.
* Use char instead of single-char String where possible.
* Prefer direct logic over inverted.
* Rename returnBlah to replyBlah.
* Renamed h2int to hexDigitToInt
* Renamed getFileError() to checkForUnsupportedPath(), to avoid confusion
with a getter.
* Misc improvements.
* Added comments about mandatory rebuilding gz and h files in case of update
to index.htm.
* Addressed a few comments.
* Improve replies: bad requests vs server error
* (reformated)
* Reduce clutter by reserving String size beforehand.
* Moved most Strings of more than 10 chars to flash.
* Use lib version of urlDecode() instead of a local one, and only call it when required.
* Added a comment about the dangers of recursion on embedded devices.
* Added a more explicit warning in the .h header comment.
* Added a typical set of required files to load ace editor from the ESP.
* (reformated)
* More explicit warning at the beginning of the .h version.
Co-authored-by: david gauchard <gauchard@laas.fr>
Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
Co-authored-by: Develo <deveyes@gmail.com>
* Update Uri.h
* Add a simple test for the new constructor
Convert a c-str to a FPSTR in the example to have a section
of code in our CI that will catch any future breaks of this specific
kind.
Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
Previously, when the path was a directory, but didn't have a slash at
the end, a 0 byte response would be sent when using LittleFS. Now, it
will return a 404, like was always the case when using SPIFFS.
* Add path args
* Add example
* Update code format
* Add missing include
* Fix codestyle and unsigned int
* fix unsigned int
* Remove tabs
* use vector<>.resize
* rename j to requestUriIndex
* using assert checking the path argument index
* Add missing include "assert.h"
* The order no longer matters.
Path arguments may not contain the value '/'
Updated the example
* make pathArg return a const
* Update PathArgServer.ino
fix trailing space
* const String&
* Add regex support
* Fix to match templating
* Add Uri with support for staticUri, regexUri and globUri
* Update example
* Add deconstructor to remove _uri pointer
* Add newline to end of files
* Suppress gcc warnings (unused params)
* Replace regex with regex.h
* Use the standard STASSID/PSK settings for example
Make the example match the existing examples which allow setting
the SSID/PSK in the local platform.txt file.
* Use 115.2Kbaud for example, match others
Co-authored-by: david gauchard <gauchard@laas.fr>
Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
Fixes#6984
When a directory index is requested with an explicit index.html, follow
the original webserver order and check for: index.htm, index.htm.gz,
index.html, index.html.gz, in order.
Fixes the regressions introduced in 9f2cfb8 and 6768116
* Remove trailing whitespace
* Improve "is file" check for LittleFS support
The previous implementation was based on a quirk of SPIFFS (that exists
returns false for directories) so it wouldn't work with LittleFS. This
implementation works with both.
Co-authored-by: Develo <deveyes@gmail.com>
* PROGMEM footprint cleanup for responseCodeToString
Doing returns with String/FlashStringHelper conversion for every
case means that the code for doing that is duplicated, which
is wasteful. doing it only once saves about 250 bytes (50%) of
code size.
* Remove "I'm a teapot" error code
* Add inline code comment to explain rationale
Use the proper api (::clear(), isEmpty()) instead of doing
comparisons/assignments of empty strings. Also fix mixture
of tabs and spaces in the source code.
The method #send(int, char*, char*[, size_t])) is a virtual method which
calculates the size of the content then calls #send_P(int, PGM_P, PGM_P,
size_t). This particular implementation of #send_P differs from the other
implementations of #send and #send_P in that it uses #sendContent for
headers and always calls #sendContent_P for contents even when the
contents is not specified.
The method #sendContent is intended for body and prepends the chunksize
in chunk mode but this breaks the HTTP protocol which does not expect a
chunksize prior to the headers.
Fix is simply to do the same thing as all the other methods - call
_currentClient.write and only call #sendContent_P if there is content to
send.
* Add const char* content to ESP8266WebSerer::send()
Supercedes #3492
Allow sending raw binary data or strings directly without conversion to
a String to reduce memory overhead when possible.
From original @timw1971 PR #3492
Added public functions to allow content to be uploaded using const
char*. For some cases, this can remove the need for content to be copied
into a String, and thus can be considerably more space-efficient.
* Fix example formatting
* Make GIF example use static const array
* Make the example really need to use const char*
Make the generated GIF dynamic in the example and move the original to
PROGMEM (since that's where const arrays like this belong).
Fixes#6792
Only append the "l" to ".htm" when there actually is a ".html" file
present. If not, fall-thru like before and try .gz through the normal
paths.
There are actually several instances where we pass in read-only
parameters as pass-by-value, where in the case of String() that
is inefficient as it involves copy-constructor/temp string creations.
We can avoid that, similarly to single character string concatenations
done via string literals instead of char literals.
* Put longer string literals into PROGMEM
* Use Flash Strings for Debug output
This is hopefully very infrequently used, so it shouldn't
be in main memory.
* Add HTTP_HEAD to HTTPMethod
* Parse the HTTP_HEAD variant of HTTPMethod from a method string
* Add HTTP_HEAD to the ESP8266WebServer constants
* Skip sending the content of the response if the HTTP method is HEAD method
* Convert the HTTP status code 418 to string
This status code is an easter egg from the IETF and is described in
[RFC2324](https://tools.ietf.org/html/rfc2324#section-2.3.2)
Fixes#2567
Allow the web server to send plain C strings instead of requring they be
encapsulated inside a String class object. Saves memory vs. having to
convert C strings to Strings (i.e. duplication of data), overloads on
the efficient sendContent_P(char*) methods.