State more explicitly that concurrent requests are not supported

This commit is contained in:
Marcel Stör 2016-05-14 13:55:25 +02:00
parent 1744372060
commit e5cd17f08b
1 changed files with 33 additions and 32 deletions

View File

@ -3,33 +3,34 @@
| :----- | :-------------------- | :---------- | :------ | | :----- | :-------------------- | :---------- | :------ |
| 2016-01-15 | [esphttpclient](https://github.com/Caerbannog/esphttpclient) / [Vowstar](https://github.com/vowstar) | [Vowstar](https://github.com/vowstar) | [http.c](../../../app/modules/http.c)| | 2016-01-15 | [esphttpclient](https://github.com/Caerbannog/esphttpclient) / [Vowstar](https://github.com/vowstar) | [Vowstar](https://github.com/vowstar) | [http.c](../../../app/modules/http.c)|
Basic HTTP *client* module. Basic HTTP *client* module that provides an interface to do GET/POST/PUT/DELETE over HTTP(S), as well as customized requests. Due to the memory constraints on ESP8266, the supported page/body size is limited by available memory. Attempting to receive pages larger than this will fail. If larger page/body sizes are necessary, consider using [`net.createConnection()`](#netcreateconnection) and stream in the data.
Provides an interface to do basic GET/POST/PUT/DELETE over HTTP(S), as well as customized requests. Due to the memory constraints on ESP8266, the supported page/body size is limited by available memory. Attempting to receive pages larger than this will fail. If larger page/body sizes are necessary, consider using [`net.createConnection()`](#netcreateconnection) and stream in the data. !!! note "Note:"
It is **not** possible to execute concurrent HTTP requests using this module. Starting a new request before the previous has completed will result in undefined behavior.
Each request method takes a callback which is invoked when the response has been received from the server. The first argument is the status code, which is either a regular HTTP status code, or -1 to denote a DNS, connection or out-of-memory failure, or a timeout (currently at 10 seconds). Each request method takes a callback which is invoked when the response has been received from the server. The first argument is the status code, which is either a regular HTTP status code, or -1 to denote a DNS, connection or out-of-memory failure, or a timeout (currently at 10 seconds).
For each operation it is also possible to include custom headers. Note that following headers *can not* be overridden however: For each operation it is also possible to include custom headers. Note that following headers *can not* be overridden however:
- Host
- Connection - Host
- User-Agent - Connection
- User-Agent
The `Host` header is taken from the URL itself, the `Connection` is always set to `close`, and the `User-Agent` is `ESP8266`. The `Host` header is taken from the URL itself, the `Connection` is always set to `close`, and the `User-Agent` is `ESP8266`.
Note that it is not possible to execute concurrent HTTP requests using this module. Starting a new request before the previous has completed will result in undefined behavior.
## http.delete() ## http.delete()
Executes a HTTP DELETE request. Executes a HTTP DELETE request. Note that concurrent requests are not supported.
#### Syntax #### Syntax
`http.delete(url, headers, body, callback)` `http.delete(url, headers, body, callback)`
#### Parameters #### Parameters
- `url` The URL to fetch, including the `http://` or `https://` prefix - `url` The URL to fetch, including the `http://` or `https://` prefix
- `headers` Optional additional headers to append, *including \r\n*; may be `nil` - `headers` Optional additional headers to append, *including \r\n*; may be `nil`
- `body` The body to post; must already be encoded in the appropriate format, but may be empty - `body` The body to post; must already be encoded in the appropriate format, but may be empty
- `callback` The callback function to be invoked when the response has been received; it is invoked with the arguments `status_code` and `body` - `callback` The callback function to be invoked when the response has been received; it is invoked with the arguments `status_code` and `body`
#### Returns #### Returns
`nil` `nil`
@ -50,15 +51,15 @@ http.delete('http://httpbin.org/delete',
## http.get() ## http.get()
Executes a HTTP GET request. Executes a HTTP GET request. Note that concurrent requests are not supported.
#### Syntax #### Syntax
`http.get(url, headers, callback)` `http.get(url, headers, callback)`
#### Parameters #### Parameters
- `url` The URL to fetch, including the `http://` or `https://` prefix - `url` The URL to fetch, including the `http://` or `https://` prefix
- `headers` Optional additional headers to append, *including \r\n*; may be `nil` - `headers` Optional additional headers to append, *including \r\n*; may be `nil`
- `callback` The callback function to be invoked when the response has been received; it is invoked with the arguments `status_code` and `body` - `callback` The callback function to be invoked when the response has been received; it is invoked with the arguments `status_code` and `body`
#### Returns #### Returns
`nil` `nil`
@ -76,16 +77,16 @@ http.get("http://httpbin.org/ip", nil, function(code, data)
## http.post() ## http.post()
Executes a HTTP POST request. Executes a HTTP POST request. Note that concurrent requests are not supported.
#### Syntax #### Syntax
`http.post(url, headers, body, callback)` `http.post(url, headers, body, callback)`
#### Parameters #### Parameters
- `url` The URL to fetch, including the `http://` or `https://` prefix - `url` The URL to fetch, including the `http://` or `https://` prefix
- `headers` Optional additional headers to append, *including \r\n*; may be `nil` - `headers` Optional additional headers to append, *including \r\n*; may be `nil`
- `body` The body to post; must already be encoded in the appropriate format, but may be empty - `body` The body to post; must already be encoded in the appropriate format, but may be empty
- `callback` The callback function to be invoked when the response has been received; it is invoked with the arguments `status_code` and `body` - `callback` The callback function to be invoked when the response has been received; it is invoked with the arguments `status_code` and `body`
#### Returns #### Returns
`nil` `nil`
@ -106,16 +107,16 @@ http.post('http://httpbin.org/post',
## http.put() ## http.put()
Executes a HTTP PUT request. Executes a HTTP PUT request. Note that concurrent requests are not supported.
#### Syntax #### Syntax
`http.put(url, headers, body, callback)` `http.put(url, headers, body, callback)`
#### Parameters #### Parameters
- `url` The URL to fetch, including the `http://` or `https://` prefix - `url` The URL to fetch, including the `http://` or `https://` prefix
- `headers` Optional additional headers to append, *including \r\n*; may be `nil` - `headers` Optional additional headers to append, *including \r\n*; may be `nil`
- `body` The body to post; must already be encoded in the appropriate format, but may be empty - `body` The body to post; must already be encoded in the appropriate format, but may be empty
- `callback` The callback function to be invoked when the response has been received; it is invoked with the arguments `status_code` and `body` - `callback` The callback function to be invoked when the response has been received; it is invoked with the arguments `status_code` and `body`
#### Returns #### Returns
`nil` `nil`
@ -136,17 +137,17 @@ http.put('http://httpbin.org/put',
## http.request() ## http.request()
Execute a custom HTTP request for any HTTP method. Execute a custom HTTP request for any HTTP method. Note that concurrent requests are not supported.
#### Syntax #### Syntax
`http.request(url, method, headers, body, callback)` `http.request(url, method, headers, body, callback)`
#### Parameters #### Parameters
- `url` The URL to fetch, including the `http://` or `https://` prefix - `url` The URL to fetch, including the `http://` or `https://` prefix
- `method` The HTTP method to use, e.g. "GET", "HEAD", "OPTIONS" etc - `method` The HTTP method to use, e.g. "GET", "HEAD", "OPTIONS" etc
- `headers` Optional additional headers to append, *including \r\n*; may be `nil` - `headers` Optional additional headers to append, *including \r\n*; may be `nil`
- `body` The body to post; must already be encoded in the appropriate format, but may be empty - `body` The body to post; must already be encoded in the appropriate format, but may be empty
- `callback` The callback function to be invoked when the response has been received; it is invoked with the arguments `status_code` and `body` - `callback` The callback function to be invoked when the response has been received; it is invoked with the arguments `status_code` and `body`
#### Returns #### Returns
`nil` `nil`