Commit Graph

67 Commits

Author SHA1 Message Date
Bob a84f16989a Make regex a define exclusive (#617)
* Change compiler error to runtime error.
Add compiler warining when a ASYNCWEBSERVER_REGEX function is used, but not enabled

* Update docs for usage in Arduino IDE

* Update docs for platform.local.txt
2019-10-14 23:06:38 +03:00
Me No Dev b9c4170528
Update README.md 2019-10-02 14:55:37 +03:00
matt123p 2f37037029 Add function so that the total number of web-socket clients can be limited (#591)
* Add function so that the total number of web-socket clients can be limited easily.  This is to cope with a problem when a browser does not close the web-socket connection correctly.  I have observed this on Chromium based browsers.  The memory leak will eventually lead to the server crashing.  Normally only one connection per client is required, so limiting the number of connections would not normally cause any problems.

* Prevent an assertion failure when using WebSockets

Frequently when using Web Sockets you will get the assert failure:
    	assertion "new_rcv_ann_wnd <= 0xffff" failed: file "/Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/lwip/lwip/src/core/tcp.c", line 779, function: tcp_update_rcv_ann_wnd

This will happen particulary when you close the browser window.  This change
prevents the issue from occuring.

* Do not use thread locking with the ESP8266, but instead use an empty placeholder class that can be used to implement locking at a later date.

* Do not use thread locking with the ESP8266, but instead use an empty placeholder class that can be used to implement locking at a later date.

* Add function so that the total number of web-socket clients can be limited easily.  This is to cope with a problem when a browser does not close the web-socket connection correctly.  I have observed this on Chromium based browsers.  The memory leak will eventually lead to the server crashing.  Normally only one connection per client is required, so limiting the number of connections would not normally cause any problems.

* Set the default number of ws clients dependent on processor.
2019-09-24 22:42:40 +03:00
me-no-dev f5ee1935c5 Update README.md 2019-09-24 22:33:23 +03:00
me-no-dev 69aaf767eb Update README.md 2019-09-24 20:13:55 +03:00
me-no-dev a627e66d53 Update README.md 2019-09-24 16:08:59 +03:00
Me No Dev 2dc705cd05
Update README.md 2019-06-22 20:36:54 +02:00
nouser2013 94271c59a6 Added example to determine interface inside callbacks (#446) 2019-06-22 18:09:47 +02:00
Marco Tombesi bde2fce07b arduino json 6 async web server migration (#491)
* arduino json 6 async web server migration

* Update .travis.yml

fix travis error

* Revert "Update .travis.yml"

This reverts commit 37d1bf0e71ad21dc502aa632c1df503820686046.

* gitignore

* test fix travis

* fix travis

* fix proposed in #487

* fix travis

* fix travis

* fix travis

* fix travis

* ARDUINOJSON_5_COMPATIBILITY

* replaced to #if ARDUINOJSON_VERSION_MAJOR == 5

* fix

* added AsyncWebServer::end()

* added AsyncWebServer::end()

* Update WebServer.cpp

fix

* fix typo

* fix typo
2019-06-22 12:20:31 +02:00
Arsène von Wyss d7399a7664 Added handler for correct JSON deserialization, addresses #195 (#287)
* Added handler for correct JSON deserialization (even with multiple body data writes), addresses #195

* Fixed typo

* Added JSON handler example to readme

* Moved Json Handler uri parameter to constructor

* Use request->_tempObject for JSON char data buffer

* Moved onRequest to constructor in JSON async handler
2018-07-24 20:56:05 +02:00
Merlin Schumacher fc71230a31 Change JSON MIME type to application/json (#311) 2018-07-24 20:13:14 +02:00
Ivan Kravets 232b87aeb1 Add Installation section and instruction for @PlatformIO (#293) 2017-11-26 01:24:07 +01:00
Alexander 054824a174 Fix server method typo in README (#280) 2017-11-06 15:46:45 +02:00
omersiar d366e7c539 This re-enables previously removed WebSocket authentication which is … (#272)
* This re-enables previously removed WebSocket authentication which is orginaly implemented PR #143

* Update README.md
2017-10-30 09:43:31 +01:00
Greg Lincoln 46eebddd76 Allow "default" headers to be defined for all responses. (#230)
* Add DefaultHeaders singleton.

* Add documentation for DefaultHeaders.
2017-09-18 13:15:49 +08:00
Me No Dev 9e300bcf90 Update README.md 2017-09-08 13:19:44 +03:00
Alexandr Zarubkin e6c432e563 Something got lost during pull request #189. Fixes #211, updates documentation. (#213)
* Removed unnecessary memmove from chunked response generation.

* Added simple template processor to AsyncFileResponse.

Unzipped files in SPIFFS, Streams, PROGMEM strings, callback/chunked responses may have template placeholders like %TEMPLATE_VAR% inside. If callback is specified in Async...Response constructor call, it will be used to replace these with actual strings.
The prototype of callback is String(const String&), i.e. it gets variable name and returns its value.
Template variables' delimiter is currently percent sign ('%').
Maximal placeholder length is 32 chars (chosen somewhat arbitrarily, it may be stored on stack during processing). It is not guaranteed that placeholders longer than that will be processed.

Signed-off-by: Alexandr Zarubkin <me21@yandex.ru>
2017-08-31 19:44:23 +03:00
Alexandr Zarubkin 0179c17cf9 Added simple template processor to AsyncFileResponse. (#189)
Unzipped files in SPIFFS, Streams, PROGMEM strings, callback/chunked responses may have template placeholders like %TEMPLATE_VAR% inside. If callback is specified in Async...Response constructor call, it will be used to replace these with actual strings.
The prototype of callback is String(const String&), i.e. it gets variable name and returns its value.
Template variables' delimiter is currently percent sign ('%').
Maximal placeholder length is 32 chars (chosen somewhat arbitrarily, it may be stored on stack during processing). It is not guaranteed that placeholders longer than that will be processed.

Signed-off-by: Alexandr Zarubkin <me21@yandex.ru>

# Conflicts:
#	src/WebResponses.cpp
2017-08-18 17:59:06 +03:00
omersiar a94265d72f Add another project that uses AsyncWebServer (#184)
Project features

- JSON object exchenged between server and browser
- Websocket
- Async Wi-Fi Scan
- SPIFFS
- Javascript
2017-06-22 12:03:16 +02:00
Jej 9bfd52529a Cache-Control header value needs = separator (not : ) (#180)
As specified here https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 the separator for Cache-Control header values is =
2017-06-21 12:36:15 +02:00
sticilface 1b35f15ec2 Web Sockets memory improvements : shared message buffer, direct buffer access (#144)
* Add support for a MultiMessage where the buffer is shared between WS messages to multiple clients.
Add ability to create a WS buffer directly and write to it, saving duplication of message in RAM, then send it.  example below is an arduinoJson message.

```cpp
void sendDataWs(AsyncWebSocketClient * client)
{
    DynamicJsonBuffer jsonBuffer;
    JsonObject& root = jsonBuffer.createObject();
    root["a"] = "abc";
    root["b"] = "abcd";
    root["c"] = "abcde";
    root["d"] = "abcdef";
    root["e"] = "abcdefg";
    size_t len = root.measureLength();
    AsyncWebSocketMessageBuffer * buffer = ws.makeBuffer(len); //  creates a buffer (len + 1) for you.
    if (buffer) {
        root.printTo((char *)buffer->get(), len + 1);
        if (client) {
            client->text(buffer);
        } else {
            ws.textAll(buffer);
        }
    }
}
```

* Add example to readme.
2017-03-14 14:55:39 +01:00
Tuan PM 9b66da2c92 Add basic auth for server static (#143)
* Add basic auth for server static

* Also effect to Websocket

* Add http basic auth for event source & document to README.md
2017-03-05 20:02:33 +02:00
hreintke 1d66bbfc77 Adding example of global & class functions for request handler (#107)
* Adding example of global & class functions for request handler

* Make title the same as the one in the table of contents
2016-12-14 03:34:21 +02:00
Me No Dev 9bdf7c42b4 Add Tinkerman (Xose Pérez) projects to README 2016-11-27 17:58:30 +02:00
me-no-dev 3e6e890808 fix indentation 2016-11-21 17:44:46 +02:00
me-no-dev 3cfb65f04d regenerate proper links 2016-11-21 17:41:34 +02:00
me-no-dev 5f062c7bc3 remove toc for now 2016-11-21 17:16:31 +02:00
Me No Dev 934937bcb4 Update README.md 2016-11-17 02:01:52 +02:00
Max Lunin 3eb639b027 Reset all handlers. This allowing to use same server few times (#93)
* Reset all handlers. This allowing to use same server few times during app life.
E.g. for WiFi manager when hardware sepups WiFi connection and as HTTP server during hardware life cycle
2016-11-17 01:16:58 +02:00
Me No Dev 03c61fab43 Update README.md
Add example how to scan WiFi Asynchronously
2016-11-05 12:35:58 +02:00
Me No Dev fbb05a2765 Update README.md 2016-07-31 23:40:31 +03:00
Me No Dev 36b7b2c0a5 Update README.md
Add example web updater
2016-07-31 23:22:06 +03:00
Me No Dev d61cc2d130 Implement sending content from progmem
make the example editor run from progmem
2016-07-21 12:25:25 +03:00
Me No Dev 7a1fd02cce Add vzero to projects in readme 2016-07-15 09:32:39 +03:00
Me No Dev 59e904362b fix some readme typos 2016-07-07 22:45:20 +03:00
Me No Dev 5137dbe0bf update readme with some EventSource examples 2016-06-29 21:58:01 +03:00
Me No Dev 49b6046125 Add Digest Web Authentication and make it default
accept htdigest formatted hashes as well
2016-06-29 16:20:03 +03:00
Me No Dev cdd1ced67a Add EventSource plugin 2016-06-28 21:51:48 +03:00
Me No Dev b5ba7f542c syntax error in readme 2016-06-25 23:05:16 +03:00
Hagai Shatz afb7dd688a New - rewrite, filters and last-modified (#47)
* New - server.rewirte() to rewrite the request url with optional get parameters injection.
New - rewrite.setFilter() and handler.setFilter() to specify a filter callback for more control on when to include them.
New - static file handler can be set with Last-Modified header value to support Not-Modified (304) response instead of serving the actual file.

* Remove clearRewrites & clearHandlers from server.mplement server distractor to delete internal members. Fixed and improved gzip stats calculation.
2016-06-25 22:04:06 +03:00
sticilface ba45a834e9 This handler will serve a 302 response to a client request for a SP… (#36)
*   This handler will serve a 302 response to a client request for a SPIFFS file if the request comes from the STA side of the ESP network.
  If the request comes from the AP side then it serves the file from SPIFFS.

* corrections.  plus readme

* Update README.md

extra space

* move wifi to cpp
2016-06-10 10:46:12 +03:00
Charles 26b2e2532b Added doc for ws.enable and ws.enabled (#33) 2016-05-25 21:13:26 +03:00
Me No Dev b64691d4f7 Add known libs and projects that use async web server 2016-05-16 12:25:55 +03:00
Me No Dev f5a68e3ff4 fix some readme typos 2016-05-15 03:49:38 +03:00
Me No Dev 8917b98332 update readme a bit 2016-05-15 03:42:27 +03:00
Charles 29b3f72e80 Added printf_P method (#31)
* Prevent buffer overflow on received data

* pass to 7 char to avoid save to flash by SDK

* return _contentLength, avoid array reparse to know len

* Added FlashStringHelper for text and binary

* Added FlashStringHelper also to AsyncWebSocketClient

* Added PROGMEM doc

* Corrected binary was sending PSTR as text, addded len

* Server calls client method and code as asked @me-no-dev

* server calls client method and code as asked by @me-no-dev

* Changed Code presentation

* Added printf_P methods
2016-05-15 03:00:33 +03:00
Charles 1d275900eb Prevent Buffer Overflow and Added FlashStringHelper for text and binary (#26)
* Prevent buffer overflow on received data

* pass to 7 char to avoid save to flash by SDK

* return _contentLength, avoid array reparse to know len

* Added FlashStringHelper for text and binary

* Added FlashStringHelper also to AsyncWebSocketClient

* Added PROGMEM doc

* Corrected binary was sending PSTR as text, addded len

* Server calls client method and code as asked @me-no-dev

* server calls client method and code as asked by @me-no-dev

* Changed Code presentation
2016-05-12 15:17:35 +03:00
Me No Dev 9d9c2b7bf4 add WebSocket info to readme 2016-04-23 15:47:27 +03:00
Me No Dev 61d6de91a6 Update README.md 2016-04-07 12:23:51 +03:00
Me No Dev 024add39d3 more readme changes 2016-02-09 03:21:48 +02:00