feat(http): Modify for esp8266

This commit is contained in:
yuanjm
2020-08-07 11:47:43 +08:00
parent 9ea5d2abe7
commit 08a4fe0d61
7 changed files with 19 additions and 6 deletions

View File

@ -4,5 +4,5 @@ idf_component_register(SRCS "esp_http_client.c"
"lib/http_utils.c" "lib/http_utils.c"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS "lib/include" PRIV_INCLUDE_DIRS "lib/include"
REQUIRES nghttp REQUIRES http_parser
PRIV_REQUIRES mbedtls lwip esp-tls tcp_transport) PRIV_REQUIRES mbedtls lwip esp-tls tcp_transport tcpip_adapter)

View File

@ -14,4 +14,10 @@ menu "ESP HTTP client"
This option will enable HTTP Basic Authentication. It is disabled by default as Basic This option will enable HTTP Basic Authentication. It is disabled by default as Basic
auth uses unencrypted encoding, so it introduces a vulnerability when not using TLS auth uses unencrypted encoding, so it introduces a vulnerability when not using TLS
config HTTP_BUF_SIZE
int "Default HTTP Buffer Size (both send and receive)"
default 512
range 512 1460
help
Set HTTP Buffer Size. The larger buffer size will make send and receive more size packet once.
endmenu endmenu

View File

@ -24,7 +24,7 @@
extern "C" { extern "C" {
#endif #endif
#define DEFAULT_HTTP_BUF_SIZE (512) #define DEFAULT_HTTP_BUF_SIZE CONFIG_HTTP_BUF_SIZE
typedef struct esp_http_client *esp_http_client_handle_t; typedef struct esp_http_client *esp_http_client_handle_t;
typedef struct esp_http_client_event *esp_http_client_event_handle_t; typedef struct esp_http_client_event *esp_http_client_event_handle_t;

View File

@ -19,7 +19,7 @@
#include "esp_netif.h" #include "esp_netif.h"
#include "lwip/sockets.h" #include "lwip/sockets.h"
#include "esp32/rom/md5_hash.h" #include "rom/md5_hash.h"
#include "mbedtls/base64.h" #include "mbedtls/base64.h"
#include "esp_system.h" #include "esp_system.h"
@ -81,6 +81,10 @@ char *http_auth_digest(const char *username, const char *password, esp_http_auth
return NULL; return NULL;
} }
if (auth_data->algorithm == NULL) {
auth_data->algorithm = "md5";
}
ha1 = calloc(1, MD5_MAX_LEN); ha1 = calloc(1, MD5_MAX_LEN);
HTTP_MEM_CHECK(TAG, ha1, goto _digest_exit); HTTP_MEM_CHECK(TAG, ha1, goto _digest_exit);

View File

@ -15,7 +15,7 @@
#ifndef _HTTP_HEADER_H_ #ifndef _HTTP_HEADER_H_
#define _HTTP_HEADER_H_ #define _HTTP_HEADER_H_
#include "sys/queue.h" #include "rom/queue.h"
#include "esp_err.h" #include "esp_err.h"
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -647,7 +647,7 @@ static void http_test_task(void *pvParameters)
void app_main(void) void app_main(void)
{ {
esp_err_t ret = nvs_flash_init(); esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_ERROR_CHECK(nvs_flash_erase()); ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init(); ret = nvs_flash_init();
} }

View File

@ -0,0 +1,3 @@
CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL=y
CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=1024
CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384