【修改】添加版本号定义,部分日志错误修改。

master
chenyong 7 years ago
parent 40c4ab8384
commit c952b17b98

@ -254,7 +254,7 @@ static int webclient_resolve_address(struct webclient_session *session, struct a
#ifdef WEBCLIENT_USING_TLS #ifdef WEBCLIENT_USING_TLS
if(session->tls_session) if(session->tls_session)
session->tls_session->host = rt_strdup(host_addr_new); session->tls_session->host = web_strdup(host_addr_new);
#endif #endif
} }
@ -270,11 +270,11 @@ static int webclient_resolve_address(struct webclient_session *session, struct a
#ifdef WEBCLIENT_USING_TLS #ifdef WEBCLIENT_USING_TLS
if(session->tls_session) if(session->tls_session)
{ {
session->tls_session->port = rt_strdup(port_str); session->tls_session->port = web_strdup(port_str);
ret = getaddrinfo(session->tls_session->host, port_str, &hint, res); ret = getaddrinfo(session->tls_session->host, port_str, &hint, res);
if (ret != 0) if (ret != 0)
{ {
rt_kprintf("getaddrinfo err: %d '%s'", ret, session->host); LOG_E("getaddrinfo err: %d '%s'", ret, session->host);
rc = -WEBCLIENT_ERROR; rc = -WEBCLIENT_ERROR;
} }
@ -484,19 +484,19 @@ int webclient_handle_response(struct webclient_session *session)
mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Last-Modified:"); mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Last-Modified:");
if (mime_ptr != RT_NULL) if (mime_ptr != RT_NULL)
{ {
session->last_modified = rt_strdup(mime_ptr); session->last_modified = web_strdup(mime_ptr);
} }
mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Transfer-Encoding: "); mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Transfer-Encoding: ");
if (mime_ptr != RT_NULL) if (mime_ptr != RT_NULL)
{ {
session->transfer_encoding = rt_strdup(mime_ptr); session->transfer_encoding = web_strdup(mime_ptr);
} }
mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Content-Type:"); mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Content-Type:");
if (mime_ptr != RT_NULL) if (mime_ptr != RT_NULL)
{ {
session->content_type = rt_strdup(mime_ptr); session->content_type = web_strdup(mime_ptr);
} }
mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Content-Length:"); mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Content-Length:");
@ -508,7 +508,7 @@ int webclient_handle_response(struct webclient_session *session)
mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Location: "); mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Location: ");
if (mime_ptr != RT_NULL) if (mime_ptr != RT_NULL)
{ {
session->location = rt_strdup(mime_ptr); session->location = web_strdup(mime_ptr);
} }
mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Content-Range:"); mime_ptr = webclient_header_skip_prefix(mimeBuffer, "Content-Range:");
@ -657,7 +657,7 @@ int webclient_connect(struct webclient_session *session, const char *URI)
/* copy host address */ /* copy host address */
if (*request) if (*request)
{ {
session->request = rt_strdup(request); session->request = web_strdup(request);
} }
#ifdef WEBCLIENT_USING_TLS #ifdef WEBCLIENT_USING_TLS
@ -667,13 +667,13 @@ int webclient_connect(struct webclient_session *session, const char *URI)
if((tls_ret = mbedtls_client_context(session->tls_session)) < 0) if((tls_ret = mbedtls_client_context(session->tls_session)) < 0)
{ {
rt_kprintf("connect failed, https client context return: -0x%x", -tls_ret); LOG_E("connect failed, https client context return: -0x%x", -tls_ret);
return -WEBCLIENT_ERROR; return -WEBCLIENT_ERROR;
} }
if((tls_ret = mbedtls_client_connect(session->tls_session)) < 0) if((tls_ret = mbedtls_client_connect(session->tls_session)) < 0)
{ {
rt_kprintf("connect failed, https client connect return: -0x%x", -tls_ret); LOG_E("connect failed, https client connect return: -0x%x", -tls_ret);
rc = -WEBCLIENT_CONNECT_FAILED; rc = -WEBCLIENT_CONNECT_FAILED;
goto __exit; goto __exit;
} }
@ -762,7 +762,7 @@ struct webclient_session *webclient_open(const char *URI)
/* relocation */ /* relocation */
if ((session->response == 302 || session->response == 301) && session->location) if ((session->response == 302 || session->response == 301) && session->location)
{ {
char *location = rt_strdup(session->location); char *location = web_strdup(session->location);
if (location) if (location)
{ {
webclient_close(session); webclient_close(session);
@ -823,7 +823,7 @@ struct webclient_session *webclient_open_position(const char *URI, int position)
/* relocation */ /* relocation */
if ((session->response == 302 || session->response == 301) && session->location) if ((session->response == 302 || session->response == 301) && session->location)
{ {
char *location = rt_strdup(session->location); char *location = web_strdup(session->location);
if (location) if (location)
{ {
webclient_close(session); webclient_close(session);

@ -66,6 +66,13 @@
#define web_free rt_free #define web_free rt_free
#endif #endif
#ifndef web_strdup
#define web_strdup rt_strdup
#endif
#define WEBCLIENT_SW_VERSION "2.0.0"
#define WEBCLIENT_SW_VERSION_NUM 0x20000
#ifndef WEBCLIENT_HEADER_BUFSZ #ifndef WEBCLIENT_HEADER_BUFSZ
#define WEBCLIENT_HEADER_BUFSZ 4096 #define WEBCLIENT_HEADER_BUFSZ 4096
#endif #endif

@ -21,7 +21,6 @@
* 2017-07-26 chenyong modify log information * 2017-07-26 chenyong modify log information
*/ */
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>

Loading…
Cancel
Save