diff --git a/frameworks/js/napi/http/include/http_enum_define.h b/frameworks/js/napi/http/include/http_enum_define.h index 802ffd3589d94c191a6aab2f120f916ac9c89105..e61b2dc19de0d77f37cc8e0d30ed96483d785f88 100644 --- a/frameworks/js/napi/http/include/http_enum_define.h +++ b/frameworks/js/napi/http/include/http_enum_define.h @@ -18,7 +18,6 @@ namespace OHOS { namespace NetManagerStandard { - enum RequestMethod { OPTIONS = 0, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT }; enum ResponseCode { diff --git a/frameworks/js/napi/http/src/http_napi.cpp b/frameworks/js/napi/http/src/http_napi.cpp index 676ed49c02f6086e307c69eb24f2d34df26aa757..56e378e6b58ed89cdef1a2b2d18a8d89210ba159 100644 --- a/frameworks/js/napi/http/src/http_napi.cpp +++ b/frameworks/js/napi/http/src/http_napi.cpp @@ -21,7 +21,6 @@ namespace OHOS { namespace NetManagerStandard { - static int32_t FindMethodIndex(const std::string &key) { std::vector methodVector = { @@ -250,7 +249,7 @@ napi_value Request(napi_env env, napi_callback_info info) &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("Queue Async Work Successful"); + NETMGR_LOGI("Queue Async Work Successful"); } return result; } @@ -361,7 +360,6 @@ napi_value On(napi_env env, napi_callback_info info) if (eventType != NONE_EVENT_TYPE) { g_eventListenerList.push_back(listener); result = thisVar; - NETMGR_LOGD("ON Finish = %{public}d", (int32_t)g_eventListenerList.size()); } return thisVar; @@ -575,7 +573,7 @@ napi_value HttpPropertyInit(napi_env env, napi_value exports) DECLARE_NAPI_STATIC_PROPERTY("VERSION", version)}; NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); - NETMGR_LOGD("HttpPropertyInit End"); + return exports; } diff --git a/frameworks/js/napi/http/src/http_request.cpp b/frameworks/js/napi/http/src/http_request.cpp index 332981bd3992a1f5ce883b563559f70d96abfeef..f5fe44c5a65999d643e9d71e4fb2710bb7609844 100644 --- a/frameworks/js/napi/http/src/http_request.cpp +++ b/frameworks/js/napi/http/src/http_request.cpp @@ -94,7 +94,7 @@ void HttpRequest::SetHeader(CURL *curl) void HttpRequest::SetOptionURL(CURL *curl, HttpRequestOptionsContext *asyncContext) { if (curl == nullptr || asyncContext == nullptr) { - NETMGR_LOGE("curl or asyncContext pointer address is empty"); + NETMGR_LOGE("The parameter of curl or asyncContext is nullptr"); return; } std::string url(asyncContext->GetUrl()); @@ -145,7 +145,7 @@ void HttpRequest::SetOptionURL(CURL *curl, HttpRequestOptionsContext *asyncConte void HttpRequest::SetMethod(CURL *curl, HttpRequestOptionsContext *asyncContext) { if (curl == nullptr || asyncContext == nullptr) { - NETMGR_LOGE("SetMethod failed"); + NETMGR_LOGE("The parameter of curl or asyncContext is nullptr"); return; } RequestMethod method = asyncContext->GetRequestMethod(); @@ -162,7 +162,7 @@ void HttpRequest::SetMethod(CURL *curl, HttpRequestOptionsContext *asyncContext) bool HttpRequest::SetOptionForPost(CURL *curl, HttpRequestOptionsContext *asyncContext) { if (curl == nullptr || asyncContext == nullptr) { - NETMGR_LOGE("set curl url option, pointer address in null"); + NETMGR_LOGE("The parameter of curl or asyncContext is nullptr"); return false; } HTTP_CURL_EASY_SET_OPTION(curl, CURLOPT_URL, asyncContext->GetUrl().c_str()); @@ -173,7 +173,7 @@ bool HttpRequest::SetOptionForPost(CURL *curl, HttpRequestOptionsContext *asyncC bool HttpRequest::SetOptionForGet(CURL *curl, HttpRequestOptionsContext *asyncContext) { if (curl == nullptr || asyncContext == nullptr) { - NETMGR_LOGE("set curl url option, pointer address in null"); + NETMGR_LOGE("The parameter of curl or asyncContext is nullptr"); return false; } @@ -220,7 +220,7 @@ bool HttpRequest::GetCurlWriteData(HttpRequestOptionsContext *asyncContext) CURL *curl = curl_easy_init(); if (curl == nullptr) { - NETMGR_LOGE("curl easy init failed"); + NETMGR_LOGE("The parameter of curl is nullptr"); return false; } SetOptionURL(curl, asyncContext); diff --git a/frameworks/js/napi/http/src/napi_util.cpp b/frameworks/js/napi/http/src/napi_util.cpp index f06920058da3da0ed16c1adaa2f7a23a42f313a6..1ec59253474c47b6348def7cf1ccefe59ebbf386 100644 --- a/frameworks/js/napi/http/src/napi_util.cpp +++ b/frameworks/js/napi/http/src/napi_util.cpp @@ -22,7 +22,6 @@ namespace OHOS { namespace NetManagerStandard { - std::string NapiUtil::ToUtf8(std::u16string str16) { return std::wstring_convert, char16_t> {}.to_bytes(str16); diff --git a/frameworks/js/napi/socket/src/socket_napi.cpp b/frameworks/js/napi/socket/src/socket_napi.cpp index 001b07659370979637011cae4926ef41021fc081..08b1785c7da68051d7d13189a321f46e1720c9ad 100644 --- a/frameworks/js/napi/socket/src/socket_napi.cpp +++ b/frameworks/js/napi/socket/src/socket_napi.cpp @@ -544,7 +544,7 @@ napi_value UdpBind(napi_env env, napi_callback_info info) &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("Udp bind Async Work Successful"); + NETMGR_LOGI("Udp bind Async Work Successful"); } return result; } @@ -612,7 +612,7 @@ napi_value UdpConnect(napi_env env, napi_callback_info info) &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("Udp connect Async Work Successful"); + NETMGR_LOGI("Udp connect Async Work Successful"); } return result; } @@ -682,7 +682,7 @@ napi_value UdpSend(napi_env env, napi_callback_info info) &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("Udp send Async Work Successful"); + NETMGR_LOGI("Udp send Async Work Successful"); } return result; } @@ -749,7 +749,7 @@ napi_value UdpClose(napi_env env, napi_callback_info info) &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("Udp send Async Work Successful"); + NETMGR_LOGI("Udp send Async Work Successful"); } return result; } @@ -760,8 +760,6 @@ napi_value UdpGetState(napi_env env, napi_callback_info info) napi_value parameters[1] = {0}; napi_value thisVar = nullptr; void *data = nullptr; - uint32_t flag = 0; - bool isFdExist = false; NAPI_CALL(env, napi_get_cb_info(env, info, ¶meterCount, parameters, &thisVar, &data)); @@ -782,22 +780,10 @@ napi_value UdpGetState(napi_env env, napi_callback_info info) return nullptr; } - for (int i = 0; i < g_onInfoList.size(); i++) { - if (objectInfo->remInfo.socketfd == g_onInfoList.at(i).socketfd) { - flag = i; - isFdExist = true; - break; - } - } - if (!isFdExist) { - return nullptr; - } - if (parameterCount == 1) { napi_valuetype valuetype1; NAPI_CALL(env, napi_typeof(env, parameters[0], &valuetype1)); if (NapiUtil::MatchValueType(env, parameters[0], napi_function)) { - NETMGR_LOGD("MatchValueType is true"); NAPI_CALL(env, napi_create_reference(env, parameters[0], 1, &(asyncContext->callbackRef_))); } } @@ -817,7 +803,7 @@ napi_value UdpGetState(napi_env env, napi_callback_info info) &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("Udp GetState Async Work Successful"); + NETMGR_LOGI("Udp GetState Async Work Successful"); } return result; @@ -886,7 +872,7 @@ napi_value UdpSetExtraOptions(napi_env env, napi_callback_info info) (void *)asyncContext, &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("Udp SetExtraOptions Async Work Successful"); + NETMGR_LOGI("Udp SetExtraOptions Async Work Successful"); } return result; } @@ -1160,7 +1146,7 @@ static void NativeTcpConnect(napi_env env, void *data) } if (asyncContext->errorCode_ >= 0) { asyncContext->isConnected = true; - asyncContext->isClose = false; // Once Connect Success ,the close state must false + asyncContext->isClose = false; std::string connect("connect"); EmitTcpEvent(asyncContext->tcpSocket_, "connect", connect); } else { @@ -1603,7 +1589,7 @@ napi_value TcpBind(napi_env env, napi_callback_info info) &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("Tcp bind Async Work Successful"); + NETMGR_LOGI("Tcp bind Async Work Successful"); } return result; @@ -1657,7 +1643,7 @@ napi_value TcpConnect(napi_env env, napi_callback_info info) &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("Tcp connect Async Work Successful"); + NETMGR_LOGI("Tcp connect Async Work Successful"); } return result; @@ -1711,7 +1697,7 @@ napi_value TcpSend(napi_env env, napi_callback_info info) &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("Udp bind Async Work Successful"); + NETMGR_LOGI("Udp bind Async Work Successful"); } return result; @@ -1768,7 +1754,7 @@ napi_value TcpClose(napi_env env, napi_callback_info info) &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("Udp close Async Work Successful"); + NETMGR_LOGI("Udp close Async Work Successful"); } return result; @@ -1822,7 +1808,7 @@ napi_value TcpGetRemoteAddress(napi_env env, napi_callback_info info) (void *)asyncContext, &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("GetRemoteAddress Async Work Successful"); + NETMGR_LOGI("GetRemoteAddress Async Work Successful"); } return result; @@ -1876,7 +1862,7 @@ napi_value TcpGetState(napi_env env, napi_callback_info info) &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("tcpGetState Async Work Successful"); + NETMGR_LOGI("tcpGetState Async Work Successful"); } return result; @@ -1935,7 +1921,7 @@ napi_value TcpSetExtraOptions(napi_env env, napi_callback_info info) (void *)asyncContext, &(asyncContext->work_))); napi_status resultStatus = napi_queue_async_work(env, asyncContext->work_); if (resultStatus == napi_ok) { - NETMGR_LOGD("tcpSetExtraOptions Async Work Successful"); + NETMGR_LOGI("tcpSetExtraOptions Async Work Successful"); } return result; }