1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +03:00

174 Commits

Author SHA1 Message Date
david gauchard
11f7d1766e remove (std::nothrow) where nullptr case is not handled
remove legacy new management
2020-08-24 09:51:58 +02:00
david gauchard
6925982284 replace new by new (std::nothrow), remove arduino_new 2020-08-17 18:15:45 +02:00
david gauchard
777323709b
webserver: add define WEBSERVER_HAS_HOOK when ::addHook() is present (#7515)
This allows conditional compilation for external libraries
2020-08-11 02:15:46 +02:00
david gauchard
1041a9d752
webhook/http1.1: prevent from losing a new client while waiting (#7492) 2020-07-30 01:26:56 +02:00
david gauchard
33083861c8
webserver hook: allow to handle external http protocol (#7459)
* 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
2020-07-28 23:34:26 +02:00
Benoît Blanchon
c18f7cb1e6
Made ESP8266WebServer::client() return a reference (fixes #7075) (#7080) 2020-07-17 02:13:29 +02:00
Zakary Kamal Ismail
3c1bd65a76
WebServer: Allow client to send many requests on the same connection (#7414)
* 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
2020-07-16 13:53:48 -07:00
david gauchard
e58bb60f87
webserver: do not count "plain" in argument list (#6768)
* webserver: do not count "plain" in argument list (it is still available though)
2020-07-13 12:40:27 +02:00
david gauchard
2d4a601c18
webserver: string optimization (#7446)
* webserver: string optimization

* fix
2020-07-10 10:11:51 -07:00
Dirk Mueller
83158affa8
Pass String by const reference [3.0] (#6583)
Passing String by value means a full copy-constructor/temporary
string creation which is slightly inefficient. Avoid that
by using const references.
2020-07-10 13:27:51 +02:00
Earle F. Philhower, III
70e4457041
Remove axTLS from code and documentation (#7437) 2020-07-09 09:21:38 -07:00
Mjxkill
7298691252
Add ESP8266WebServerTemplate<ServerType>::enableCORS(bool _ec) (#7388)
Add ESP8266WebServerTemplate<ServerType>::enableCORS(bool _ec) like ESP32 Arduino platform.
2020-06-21 14:38:32 -07:00
s-hadinger
7c008e31bb
Flash size reduction for mime-type (#7312)
* 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
2020-05-18 20:16:11 -07:00
vdeconinck
a9cf12fcf0
Make getContentType available for 3rd party usage (#7254)
* Refactored to make getContentType public for 3rd party use.

* Added missing "jpeg" extension

* Use getContentType() from mime namespace.

* Also add .jpeg extension
2020-04-29 23:36:42 -04:00
david gauchard
d600cc7fa6
Expose webserver's chunk api (#7134)
* expose hidden WebServer's chunked API
2020-04-06 20:49:34 -04:00
Develo
2b640c0189
Add flash helper constructor to Uri (#7105)
* 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>
2020-02-23 11:29:47 -08:00
JasperHorn
d990ff9547
Improve LittleFS support (#7071)
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.
2020-02-23 09:38:40 +01:00
Bob
4eca62cb53
Add Uri with support for regexUri and globUri (#6696)
* 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>
2020-02-22 16:51:47 -03:00
Earle F. Philhower, III
dbd7b8218d
Fix serach order for index.htm(l)(.gz) files (#7069)
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
2020-02-09 15:58:06 -03:00
JasperHorn
8242d72271 Add LittleFS support to ESP8266WebServer.serveStatic() (#6987)
* 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>
2020-01-04 20:33:05 -08:00
Dirk Mueller
bea9cfc3a0 PROGMEM footprint cleanup for responseCodeToString (#6950)
* 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
2019-12-27 19:02:57 -03:00
Dirk Mueller
698ffc3498 Various String handling cleanups (#6945)
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.
2019-12-26 17:03:18 -03:00
jennytoo
70c337001c Fix sending headers in #send_P(int, PGM_P, PGM_P, size_t) (#6881)
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.
2019-12-10 09:47:26 +01:00
Matthias Hertel
a738884387 Handle HEAD requests for static files correctly (#6837)
* Handle HEAD requests for static files correctly

* Handle HEAD requests for static files correctly
2019-12-04 18:23:25 +01:00
david gauchard
326083044a
webserver: fix sending char* (#6878)
* webserver: fix sending char*

* add missing char*  overload
2019-12-04 00:51:51 +01:00
david gauchard
8ec93dcd26 use wificlient.available() where relevant (#6827) 2019-11-23 20:12:37 -03:00
Earle F. Philhower, III
36f903443b Add const char* content to ESP8266WebServer::send() (#6797)
* 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).
2019-11-19 14:46:30 -03:00
Earle F. Philhower, III
6768116b8c Only add "l" to XX.htm URLs if XX.html exists (#6794)
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.
2019-11-19 02:43:47 -03:00
Develo
98785f7cdf
Rollback setContentLength removal (#6715) (#6719)
Apparently I messed up testing #6715 and something broke. This rolls back that PR.
That means #2132 remains closed with no action.
2019-11-06 16:08:28 -03:00
Develo
ffa9e3c7c2
Remove useless call to setContentLength() (#6715)
* Update ESP8266WebServer-impl.h

Remove useless call to setContentLength()

* Fix warning unused param
2019-11-05 21:50:52 -03:00
Dirk Mueller
8bc5a10d6d Further const correctness / String by reference passing cleanups (#6571)
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.
2019-10-31 16:02:39 +01:00
George Talusan
9f2cfb8218 fallback onto index.html if index.htm fails (#2614) 2019-10-29 20:25:03 -03:00
Dirk Mueller
3890e1af1e Put longer string literals into PROGMEM (#6588)
* 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.
2019-10-03 23:17:36 -03:00
Zakary Kamal Ismail
0dbb04e881 Add HTTP_HEAD to HTTPMethod and parse it (#6413)
* 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)
2019-08-17 11:58:40 -07:00
Earle F. Philhower, III
aa0bc3372f Add plain char* signatures WebServer::sendContent (#6341)
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.
2019-07-25 13:39:57 +02:00
david gauchard
5cb82c1610
webserver: restore legacy request handler (#6321) 2019-07-20 08:29:02 +02:00
Earle F. Philhower, III
7036297920 Convert ESP8266WebServer* into templatized model (#5982)
* Convert ESP8266WebServer* into templatized model

Supercedes #4912

Refactor the three versions of ESP8266WebServer and *WebServerSecure to a
single templated class. Use "using" to enable old, non-templated names to b
used (so no user changes required to compile or run).

Fixes #4908 and clean up the code base a lot.

Basic tests run (the ones in the example code).

No code changes are required in userland except for setting the SSL
certificates which now use a cleaner "getServer()" accessor and lets the
app use the native BearSSL calls on the WiFiClientSecure object.

@devyte should be proud, it removes virtuals and even has template specialization...

* Fix HTTPUpdate templates and examples

* Fix HTTPUpdateServer library build

Need to remove dot-a linkage since there are no .cpp files in the
directory anymore due to templates.

* Provide backward-compat names for updt template

Allow existing code to use the same well known names for
HTTPUpdateSecure.

* Remove ClientType from all templates, auto-infer

Remove the ClientType template parameter from all objects.  Simplifies
the code and makes it more foolproof.

Add a "using" in each server to define the type of connection returned
by all servers, which is then used in the above templates automatically.

* Can safely include FS.h now that SD/SPIFFS unified

* Move the templates/objects to their own namespaces

* Fix merge issues with untemplated methods

* Address review comments

* Fix mock test, remove warnings inside test dir

Make the simple mock test CI job pass and clean up
any spurious warnings in the test directory.

There still are warnings in the libraries and core, but they
should be addressed in a separate PR.
2019-07-04 10:58:22 +02:00
Tyler Moore
6191fbbd92 Modified ESP8266WebServer (#6020)
-Expose HTTP Digest authentication with H1 hash as the argument
-Preserved HTTP authentication with username/password arguments
-Added a public  static function for generating the H1 hash
-Created an example of how to use this called HttpHashCredAuth.ino
2019-05-23 09:57:51 -07:00
Allman-astyler
eea9999dc5 Revert "Allman now (#6080)" (#6090)
This reverts commit 98125f88605cd7e46e9be4e1b3ad0600dd5d2b51.
2019-05-14 00:09:54 +02:00
Allman-astyler
98125f8860 Allman now (#6080)
* switch restyle script for CI

* remove confirmation

* restyle with allman
2019-05-13 16:41:34 +02:00
david gauchard
2528013c5d
small addons (#5847)
* make (static) ESP8266WebServer::responseCodeToString visible and usable
* esp8266:coreVersionNumeric(): add a define and comment-example to check on its usability
2019-03-07 11:37:38 +01:00
dav1901
c08efb52fb Adjust send_P to function the same as send (#5507) 2019-02-07 20:39:20 +00:00
lukasostendorf
3a36501d6d Fix: some clients were not able to authenticate using DIGEST_AUTH (#5506) 2018-12-18 14:52:14 -03:00
david gauchard
92373a9837 Deprecate axTLS, update examples (#5366)
* update examples

* fix serial<->tcp example, use STASSID instead of SSID (name collision)

* fix HTTPSRequest.ino

* update AxTLS HTTPS examples, update AxTLS API to deprecated

* fixes

* fixes + fix astyle (no preproc directives) + restyling script

* fix HTTPClient library

* fixes

* common.sh: do not reload arduino when already present (for locally CI testing)

* common.sh: do not reload ArduinoJson when already present (for locally CI testing)

* fix

* fix

* fix deprecated example

* fix WiFiHTTPSServer.ino

* reduce footprint

* wipfix

* fix led builtin

* fix example

* finished updating APSSID on all examples

* style

* restyle examples

* helper to run CI test locally

* local CI runner more verbose

* +const

* deprecation deprecation

* deprecation

* Update NTPClient.ino

const char[] => const char *

* Update interactive.ino

const char[] => const char *
2018-11-29 20:49:27 -08:00
DiamondDrake
8f28c88f9c Added naive content length to upload struct (#5142)
Content length provides context into the size of the upload, it's not
the exact form body size it's off by the request header info, but it was
already parsed by the library and provides little to no additional
overhead to pass on for use in request handlers.
2018-11-29 17:24:55 -08:00
Luc
440a3aae7f Expose post args during upload (#4935)
Currently post args are only available at the end of upload but they are already listed - this PR just expose them with minimal changes
It also set a define for post args array size originaly set to 32
2018-11-29 13:52:55 -08:00
david gauchard
74ca42f829 Sketch emulation on host (#5342)
* WIP compile examples on host with 'make examples'

* WIP bufferize tcp input

* WIP Makefile

* WIP network to rework, tcp/udp to factorize, udp addresses broken

* minor changes to the core

* WIP basic udp working

* WIP mdns

* WIP mcast receiving, not sending

* WIP mdns OK

* beta version

* SSL + doc

* update travis host test command

* licenses

* typo

* doc: arduino builder is not around: declare functions before calling them

* fix with latest SSL PR, compile in 32 bits mode

* fix make clean

* make -m32 optional

* 32bits compiler ability tester

* WIP

* WIP (fix 1 vtable error, still another one to hunt with using spiffs)

* example astyle

* fix os_printf_plus

* load / save mock spiffs

* fix style

* fix using spiffs/mock

* don't mess ram

* update doc

* remove leftover

* optimization -Os except for CI, rename ARCH32 to FORCE32

* revert useless cast (not even compiled)

* remove unused function

* use proper type for pointer arithmetics

* makefile: sketch object and cpp file moved to bin/ directories
easier to clean, and IDE don't like them

* changes for review

* make use of %zd

* less verbose makefile by default (option)

* update readme
2018-11-20 18:51:45 -02:00
Earle F. Philhower, III
233d3e3b5e
Move BearSSLHelpers into BearSSL namespace (#5315)
BearSSLX509List, BearSSLSession, BearSSLPublicKey, and BearSSLPrivateKey
were all in the global namespace and not in the BearSSL:: one, due to an
oversight when they were originally created.  Move them to the proper
namespace with the following mapping:
    BearSSLX509List => BearSSL::X509List
    BearSSLSession => BearSSL::Session
    BearSSLPublicKey => BearSSL::PublicKey
    BearSSLPrivateKey => BearSSL::PrivateKey
2018-11-06 19:27:40 -08:00
david gauchard
a063c2b36f
fix http parsing (#5262)
* follows #5252
* use const refs where relevant (aka stop being nasty with ram and cpu)
2018-10-23 22:17:54 +02:00
fabianoms
ad7cb635ed Improved parameter validation (#5256) 2018-10-17 17:08:38 -03:00