forked from me-no-dev/ESPAsyncWebServer
readme: fix buffers, add links
This commit is contained in:
17
README.md
17
README.md
@@ -1,10 +1,12 @@
|
|||||||
# ESPAsyncWebServer
|
# ESPAsyncWebServer
|
||||||
|
|
||||||
[](https://gitter.im/me-no-dev/ESPAsyncWebServer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
For help and support [](https://gitter.im/me-no-dev/ESPAsyncWebServer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
Async Web Server for ESP8266 Arduino
|
|
||||||
|
Async Web Server for ESP8266 and ESP31B Arduino
|
||||||
|
|
||||||
Requires [ESPAsyncTCP](https://github.com/me-no-dev/ESPAsyncTCP) to work
|
Requires [ESPAsyncTCP](https://github.com/me-no-dev/ESPAsyncTCP) to work
|
||||||
|
|
||||||
To use this library you need to have the latest git versions of either ESP8266 or ESP31B Arduino Core
|
To use this library you need to have the latest git versions of either [ESP8266](https://github.com/esp8266/Arduino) or [ESP31B](https://github.com/me-no-dev/ESP31B) Arduino Core
|
||||||
|
|
||||||
## Why should you care
|
## Why should you care
|
||||||
- Using asynchronous network means that you can handle more than one connection at the same time
|
- Using asynchronous network means that you can handle more than one connection at the same time
|
||||||
@@ -14,6 +16,7 @@ To use this library you need to have the latest git versions of either ESP8266 o
|
|||||||
- Speed is OMG
|
- Speed is OMG
|
||||||
- Easy to use API, HTTP Basic Authentication, ChunkedResponse
|
- Easy to use API, HTTP Basic Authentication, ChunkedResponse
|
||||||
- Easily extendible to handle any type of content
|
- Easily extendible to handle any type of content
|
||||||
|
- Supports Continue 100
|
||||||
|
|
||||||
## Important things to remember
|
## Important things to remember
|
||||||
- This is fully asynchronous server and as such does not run on the loop thread.
|
- This is fully asynchronous server and as such does not run on the loop thread.
|
||||||
@@ -220,7 +223,7 @@ request->send(response);
|
|||||||
### Respond with content using a callback
|
### Respond with content using a callback
|
||||||
```cpp
|
```cpp
|
||||||
//send 128 bytes as plain text
|
//send 128 bytes as plain text
|
||||||
request->send("text/plain", 128, [](uint8_t buffer, size_t maxLen) -> size_t {
|
request->send("text/plain", 128, [](uint8_t *buffer, size_t maxLen) -> size_t {
|
||||||
//Write up to "maxLen" bytes into "buffer" and return the amount written.
|
//Write up to "maxLen" bytes into "buffer" and return the amount written.
|
||||||
//You will not be asked for more bytes once the content length has been reached.
|
//You will not be asked for more bytes once the content length has been reached.
|
||||||
//Keep in mind that you can not delay or yield waiting for more data!
|
//Keep in mind that you can not delay or yield waiting for more data!
|
||||||
@@ -232,7 +235,7 @@ request->send("text/plain", 128, [](uint8_t buffer, size_t maxLen) -> size_t {
|
|||||||
### Respond with content using a callback and extra headers
|
### Respond with content using a callback and extra headers
|
||||||
```cpp
|
```cpp
|
||||||
//send 128 bytes as plain text
|
//send 128 bytes as plain text
|
||||||
AsyncWebServerResponse *response = request->beginResponse("text/plain", 128, [](uint8_t buffer, size_t maxLen) -> size_t {
|
AsyncWebServerResponse *response = request->beginResponse("text/plain", 128, [](uint8_t *buffer, size_t maxLen) -> size_t {
|
||||||
//Write up to "maxLen" bytes into "buffer" and return the amount written.
|
//Write up to "maxLen" bytes into "buffer" and return the amount written.
|
||||||
//You will not be asked for more bytes once the content length has been reached.
|
//You will not be asked for more bytes once the content length has been reached.
|
||||||
//Keep in mind that you can not delay or yield waiting for more data!
|
//Keep in mind that you can not delay or yield waiting for more data!
|
||||||
@@ -280,14 +283,14 @@ request->send(response);
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Bad Responses
|
## Bad Responses
|
||||||
Some responses that are implemented but you should not use as they do not conform to HTTP
|
Some responses that are implemented but you should not use as they do not conform to HTTP.
|
||||||
The following two examples will lead to unclean close of the connection and more time wasted
|
The following two examples will lead to unclean close of the connection and more time wasted
|
||||||
than providing the length of the content
|
than providing the length of the content
|
||||||
|
|
||||||
### Respond with content using a callback without content length
|
### Respond with content using a callback without content length
|
||||||
```cpp
|
```cpp
|
||||||
//This is used as fallback for chunked responses to HTTP/1.0 Clients
|
//This is used as fallback for chunked responses to HTTP/1.0 Clients
|
||||||
request->send("text/plain", 0, [](uint8_t buffer, size_t maxLen) -> size_t {
|
request->send("text/plain", 0, [](uint8_t *buffer, size_t maxLen) -> size_t {
|
||||||
//Write up to "maxLen" bytes into "buffer" and return the amount written.
|
//Write up to "maxLen" bytes into "buffer" and return the amount written.
|
||||||
//You will be asked for more data until 0 is returned
|
//You will be asked for more data until 0 is returned
|
||||||
//Keep in mind that you can not delay or yield waiting for more data!
|
//Keep in mind that you can not delay or yield waiting for more data!
|
||||||
|
Reference in New Issue
Block a user