• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef COMMUNICATIONNETSTACK_REQUEST_CONTEXT_H
17 #define COMMUNICATIONNETSTACK_REQUEST_CONTEXT_H
18 
19 #include "http_request_options.h"
20 #include "http_response.h"
21 #include "netstack_base_context.h"
22 #include "nocopyable.h"
23 
24 namespace OHOS::NetStack {
25 class RequestContext final : public BaseContext {
26 public:
27     DISALLOW_COPY_AND_MOVE(RequestContext);
28 
29     RequestContext() = delete;
30 
31     explicit RequestContext(napi_env env, EventManager *manager);
32 
33     void ParseParams(napi_value *params, size_t paramsCount);
34 
35     HttpRequestOptions options;
36 
37     HttpResponse response;
38 
39 private:
40     bool CheckParamsType(napi_value *params, size_t paramsCount);
41 
42     void ParseNumberOptions(napi_value optionsValue);
43 
44     void ParseHeader(napi_value optionsValue);
45 
46     bool ParseExtraData(napi_value optionsValue);
47 
48     bool GetRequestBody(napi_value extraData);
49 
50     void UrlAndOptions(napi_value urlValue, napi_value optionsValue);
51 };
52 } // namespace OHOS::NetStack
53 
54 #endif /* COMMUNICATIONNETSTACK_REQUEST_CONTEXT_H */
55