1 /*
2  * Copyright 2009-2017 Alibaba Cloud All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <alibabacloud/oss/http/HttpRequest.h>
18 
19 using namespace AlibabaCloud::OSS;
20 
MethodToString(Method method)21 std::string Http::MethodToString(Method method)
22 {
23     static const char* name[] = {"GET", "HEAD", "POST", "PUT", "DELETE",
24         "CONNECT", "OPTIONS", "PATCH", "TRACE"};
25     return name[(method - Http::Method::Get)];
26 }
27 
SchemeToString(Scheme scheme)28 std::string Http::SchemeToString(Scheme scheme)
29 {
30     static const char* name[] = {"http", "https"};
31     return name[scheme - Http::Scheme::HTTP];
32 }
33 
34 const char* Http::ACCEPT = "Accept";
35 const char* Http::ACCEPT_CHARSET = "Accept-Charset";
36 const char* Http::ACCEPT_ENCODING = "Accept-Encoding";
37 const char* Http::ACCEPT_LANGUAGE = "Accept-Language";
38 const char* Http::AUTHORIZATION = "Authorization";
39 const char* Http::CACHE_CONTROL = "Cache-Control";
40 const char* Http::CONTENT_DISPOSITION = "Content-Disposition";
41 const char* Http::CONTENT_ENCODING = "Content-Encoding";
42 const char* Http::CONTENT_LENGTH = "Content-Length";
43 const char* Http::CONTENT_MD5 = "Content-MD5";
44 const char* Http::CONTENT_RANGE = "Content-Range";
45 const char* Http::CONTENT_TYPE = "Content-Type";
46 const char* Http::DATE = "Date";
47 const char* Http::EXPECT = "Expect";
48 const char* Http::EXPIRES = "Expires";
49 const char* Http::ETAG = "ETag";
50 const char* Http::LAST_MODIFIED = "Last-Modified";
51 const char* Http::RANGE = "Range";
52 const char* Http::USER_AGENT = "User-Agent";
53 
54 
HttpRequest(Http::Method method)55 HttpRequest::HttpRequest(Http::Method method) :
56     HttpMessage(),
57     method_(method),
58     url_(),
59     responseStreamFactory_(nullptr),
60     hasCheckCrc64_(false),
61     crc64Result_(0),
62     transferedBytes_(0)
63 {
64 }
65 
~HttpRequest()66 HttpRequest::~HttpRequest()
67 {
68 }
69 
method() const70 Http::Method HttpRequest::method() const
71 {
72     return method_;
73 }
74 
75 
setMethod(Http::Method method)76 void HttpRequest::setMethod(Http::Method method)
77 {
78     method_ = method;
79 }
80 
setUrl(const Url & url)81 void HttpRequest::setUrl(const Url &url)
82 {
83     url_ = url;
84 }
85 
url() const86 Url HttpRequest::url()const
87 {
88     return url_;
89 }
90