diff --git a/frameworks/js/napi/http/include/http_request.h b/frameworks/js/napi/http/include/http_request.h index 07097621c89ab50c2560f4cf41d27d0ca86c0e88..9041b835912842f93dfab1983fc6c39153b343ca 100644 --- a/frameworks/js/napi/http/include/http_request.h +++ b/frameworks/js/napi/http/include/http_request.h @@ -16,15 +16,15 @@ #ifndef HTTP_REQUEST_H #define HTTP_REQUEST_H +#include +#include + #include "base/security/deviceauth/deps_adapter/os_adapter/interfaces/linux/hc_log.h" #include "http_request_options_context.h" #include "netmgr_log_wrapper.h" #include -#include -#include - #define HTTP_CURL_EASY_SET_OPTION(handle, opt, data) \ do { \ CURLcode result = curl_easy_setopt(handle, opt, data); \ diff --git a/frameworks/js/napi/http/include/http_request_options_context.h b/frameworks/js/napi/http/include/http_request_options_context.h index a2cd327d5d80bec6e3892b7f32d7e5a4eaf1131a..db177107dcf97d7b6590fcce832689cac8df8b36 100644 --- a/frameworks/js/napi/http/include/http_request_options_context.h +++ b/frameworks/js/napi/http/include/http_request_options_context.h @@ -149,7 +149,7 @@ private: int32_t ifModifiedSince_ = 0; bool usingCache_ = true; int32_t fixedLengthStreamingMode_ = -1; - std::string url_ = ""; + std::string url_ = ""; HttpResponse responseData_; std::string cafile_; }; diff --git a/frameworks/js/napi/http/src/http_request.cpp b/frameworks/js/napi/http/src/http_request.cpp index ef5965be3b6789fe78811e4ee84fb98277ab0573..3a89966af2a24b04de22874772c442c5d1f68b60 100644 --- a/frameworks/js/napi/http/src/http_request.cpp +++ b/frameworks/js/napi/http/src/http_request.cpp @@ -24,6 +24,7 @@ namespace OHOS { namespace NetManagerStandard { std::string URL_SEPARATOR = "?"; std::string URL_DELIMITER = "&"; +constexpr int32_t HEADER_OFFSET = 2; HttpRequest::HttpRequest() { @@ -71,7 +72,8 @@ void HttpRequest::SetHeaders(std::string headersStr) if (std::string::npos == posColon) { headers_["null"] = "[\"" + header + "\"]"; } else { - headers_["\"" + header.substr(0, posColon) + "\""] = "[\"" + header.substr(posColon + 2) + "\"]"; + headers_["\"" + header.substr(0, posColon) + "\""] = "[\"" + header.substr(posColon + + HEADER_OFFSET) + "\"]"; } headersStr = headersStr.substr(posSeparator + 1); posSeparator = headersStr.find(separator); @@ -288,7 +290,8 @@ void HttpRequest::EmitHeader(HttpRequest *obj, const std::string &header) callbackValues[1] = object; napi_value callbackResult = nullptr; - napi_call_function(env, undefine, callbackFunc, 2, callbackValues, &callbackResult); + napi_call_function(env, undefine, callbackFunc, std::size(callbackValues), callbackValues, + &callbackResult); napi_close_handle_scope(env, scope); napi_delete_reference(env, listenerIterator->callbackRef_); break; diff --git a/frameworks/js/napi/http/src/napi_util.cpp b/frameworks/js/napi/http/src/napi_util.cpp index e8f9e1f5b791d6fae055dd139b9f5aee4b91fe9a..f06920058da3da0ed16c1adaa2f7a23a42f313a6 100644 --- a/frameworks/js/napi/http/src/napi_util.cpp +++ b/frameworks/js/napi/http/src/napi_util.cpp @@ -16,10 +16,7 @@ #include "napi_util.h" #include -#include #include -#include -#include #include "netmgr_log_wrapper.h" @@ -158,7 +155,6 @@ std::string NapiUtil::GetStringFromValue(napi_env env, napi_value value) char msgChars[MAX_TEXT_LENGTH] = {0}; size_t msgLength = 0; NAPI_CALL_BASE(env, napi_get_value_string_utf8(env, value, msgChars, MAX_TEXT_LENGTH, &msgLength), ""); - NETMGR_LOGD("NapiUtil GetStringFromValue msgLength = %{public}d", msgLength); if (msgLength > 0) { return std::string(msgChars, 0, msgLength); } else { diff --git a/frameworks/js/napi/websocket/include/websocket_napi.h b/frameworks/js/napi/websocket/include/websocket_napi.h index 4dfdaf1994b09b1cc65aa722fc2a0b510377d8f9..dc70feb7ebec0fae16f9e2938b2fccd35c0e5543 100644 --- a/frameworks/js/napi/websocket/include/websocket_napi.h +++ b/frameworks/js/napi/websocket/include/websocket_napi.h @@ -21,7 +21,6 @@ namespace OHOS { namespace NetManagerStandard { - } // namespace NetManagerStandard } // namespace OHOS #endif // WEBSOCKET_NAPI_H \ No newline at end of file diff --git a/frameworks/js/napi/websocket/src/websocket_napi.cpp b/frameworks/js/napi/websocket/src/websocket_napi.cpp index 0097029c46a19a060228f8249c1305105568ed3a..08db278c9e5449b6007032ffeb53b59112a45cb1 100644 --- a/frameworks/js/napi/websocket/src/websocket_napi.cpp +++ b/frameworks/js/napi/websocket/src/websocket_napi.cpp @@ -18,7 +18,5 @@ namespace OHOS { namespace NetManagerStandard { -//DEFINE_NETMANAGER_NAPI_LOG_LABEL("WebSocketNapi"); - } // namespace NetManagerStandard } // namespace OHOS diff --git a/interfaces/kits/js/basic.d.ts b/interfaces/kits/js/basic.d.ts deleted file mode 100644 index 09a3400c33c080a206b27c287a523863c96af978..0000000000000000000000000000000000000000 --- a/interfaces/kits/js/basic.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// basic.d.ts -export interface AsyncCallback { - (err: BusinessError, data: T): void; -} - -export interface BusinessError extends Error { - code: number; -} - -export interface ErrorCallback { - (err: BusinessError): void; -} - -export interface Callback { - (data: T): void; -}