Call HTTP callback in all cases (#2020)
* fix 2007 Call callback in all cases, call callback with errorcode -1 if no connection could be establioshed * change logging from ERR to DEBUG * make debug output more clear (hopefully) * add handling of errors to docs, note error handling on every call instead of only in the main documentation
This commit is contained in:
parent
e2fc37fa17
commit
15b4fa24fd
|
@ -451,20 +451,33 @@ static void ICACHE_FLASH_ATTR http_timeout_callback( void *arg )
|
||||||
struct espconn * conn = (struct espconn *) arg;
|
struct espconn * conn = (struct espconn *) arg;
|
||||||
if ( conn == NULL )
|
if ( conn == NULL )
|
||||||
{
|
{
|
||||||
|
HTTPCLIENT_DEBUG( "Connection is NULL" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( conn->reverse == NULL )
|
if ( conn->reverse == NULL )
|
||||||
{
|
{
|
||||||
|
HTTPCLIENT_DEBUG( "Connection request data (reverse) is NULL" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
request_args_t * req = (request_args_t *) conn->reverse;
|
request_args_t * req = (request_args_t *) conn->reverse;
|
||||||
|
HTTPCLIENT_DEBUG( "Calling disconnect" );
|
||||||
/* Call disconnect */
|
/* Call disconnect */
|
||||||
|
sint8 result;
|
||||||
#ifdef CLIENT_SSL_ENABLE
|
#ifdef CLIENT_SSL_ENABLE
|
||||||
if ( req->secure )
|
if ( req->secure )
|
||||||
espconn_secure_disconnect( conn );
|
result = espconn_secure_disconnect( conn );
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
espconn_disconnect( conn );
|
result = espconn_disconnect( conn );
|
||||||
|
|
||||||
|
if (result == ESPCONN_OK || result == ESPCONN_INPROGRESS)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* not connected; execute the callback ourselves. */
|
||||||
|
HTTPCLIENT_DEBUG( "manually Calling disconnect callback due to error %d", result );
|
||||||
|
http_disconnect_callback( arg );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ Executes a HTTP DELETE request. Note that concurrent requests are not supported.
|
||||||
- `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`, `body` and `headers`
|
- `callback` The callback function to be invoked when the response has been received or an error occurred; it is invoked with the arguments `status_code`, `body` and `headers`. In case of an error `status_code` is set to -1.
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
`nil`
|
`nil`
|
||||||
|
@ -62,7 +62,7 @@ Executes a HTTP GET request. Note that concurrent requests are not supported.
|
||||||
#### 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`, `body` and `headers`
|
- `callback` The callback function to be invoked when the response has been received or an error occurred; it is invoked with the arguments `status_code`, `body` and `headers`. In case of an error `status_code` is set to -1
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
`nil`
|
`nil`
|
||||||
|
@ -89,7 +89,7 @@ Executes a HTTP POST request. Note that concurrent requests are not supported.
|
||||||
- `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`, `body` and `headers`
|
- `callback` The callback function to be invoked when the response has been received or an error occurred; it is invoked with the arguments `status_code`, `body` and `headers`. In case of an error `status_code` is set to -1.
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
`nil`
|
`nil`
|
||||||
|
@ -119,7 +119,7 @@ Executes a HTTP PUT request. Note that concurrent requests are not supported.
|
||||||
- `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`, `body` and `headers`
|
- `callback` The callback function to be invoked when the response has been received or an error occurred; it is invoked with the arguments `status_code`, `body` and `headers`. In case of an error `status_code` is set to -1.
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
`nil`
|
`nil`
|
||||||
|
@ -150,7 +150,7 @@ Execute a custom HTTP request for any HTTP method. Note that concurrent requests
|
||||||
- `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`, `body` and `headers`
|
- `callback` The callback function to be invoked when the response has been received or an error occurred; it is invoked with the arguments `status_code`, `body` and `headers`. In case of an error `status_code` is set to -1.
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
`nil`
|
`nil`
|
||||||
|
|
Loading…
Reference in New Issue