kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'bugfix/http_code_v4.4' into 'release/v4.4'
esp_http_client, esp_https_ota: Handle HTTP 303 status code (v4.4) See merge request espressif/esp-idf!17732pull/8934/head
commit
2afe86be7f
|
@ -824,7 +824,9 @@ static esp_err_t esp_http_check_response(esp_http_client_handle_t client)
|
|||
switch (client->response->status_code) {
|
||||
case HttpStatus_MovedPermanently:
|
||||
case HttpStatus_Found:
|
||||
case HttpStatus_SeeOther:
|
||||
case HttpStatus_TemporaryRedirect:
|
||||
case HttpStatus_PermanentRedirect:
|
||||
esp_http_client_set_redirection(client);
|
||||
client->redirect_counter ++;
|
||||
client->process_again = 1;
|
||||
|
|
|
@ -149,7 +149,9 @@ typedef enum {
|
|||
HttpStatus_MultipleChoices = 300,
|
||||
HttpStatus_MovedPermanently = 301,
|
||||
HttpStatus_Found = 302,
|
||||
HttpStatus_SeeOther = 303,
|
||||
HttpStatus_TemporaryRedirect = 307,
|
||||
HttpStatus_PermanentRedirect = 308,
|
||||
|
||||
/* 4xx - Client Error */
|
||||
HttpStatus_BadRequest = 400,
|
||||
|
|
|
@ -41,12 +41,29 @@ struct esp_https_ota_handle {
|
|||
|
||||
typedef struct esp_https_ota_handle esp_https_ota_t;
|
||||
|
||||
static bool redirection_required(int status_code)
|
||||
{
|
||||
switch (status_code) {
|
||||
case HttpStatus_MovedPermanently:
|
||||
case HttpStatus_Found:
|
||||
case HttpStatus_SeeOther:
|
||||
case HttpStatus_TemporaryRedirect:
|
||||
case HttpStatus_PermanentRedirect:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool process_again(int status_code)
|
||||
{
|
||||
switch (status_code) {
|
||||
case HttpStatus_MovedPermanently:
|
||||
case HttpStatus_Found:
|
||||
case HttpStatus_SeeOther:
|
||||
case HttpStatus_TemporaryRedirect:
|
||||
case HttpStatus_PermanentRedirect:
|
||||
case HttpStatus_Unauthorized:
|
||||
return true;
|
||||
default:
|
||||
|
@ -58,7 +75,7 @@ static bool process_again(int status_code)
|
|||
static esp_err_t _http_handle_response_code(esp_http_client_handle_t http_client, int status_code)
|
||||
{
|
||||
esp_err_t err;
|
||||
if (status_code == HttpStatus_MovedPermanently || status_code == HttpStatus_Found || status_code == HttpStatus_TemporaryRedirect) {
|
||||
if (redirection_required(status_code)) {
|
||||
err = esp_http_client_set_redirection(http_client);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "URL redirection Failed");
|
||||
|
|
Ładowanie…
Reference in New Issue