File tree Expand file tree Collapse file tree 5 files changed +50
-2
lines changed Expand file tree Collapse file tree 5 files changed +50
-2
lines changed Original file line number Diff line number Diff line change 2020#include < alibabacloud/oss/Types.h>
2121#include < alibabacloud/oss/auth/CredentialsProvider.h>
2222#include < alibabacloud/oss/http/HttpClient.h>
23+ #include < alibabacloud/oss/http/HttpInterceptor.h>
2324#include < alibabacloud/oss/utils/Executor.h>
2425
2526namespace AlibabaCloud
@@ -135,6 +136,11 @@ namespace OSS
135136 * signature version. default is V1.
136137 */
137138 SignatureVersionType signatureVersion;
139+
140+ /* *
141+ * Your http interceptor implement
142+ */
143+ std::shared_ptr<HttpInterceptor> httpInterceptor;
138144 };
139145}
140146}
Original file line number Diff line number Diff line change 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+ #pragma once
18+
19+ #include < string>
20+ #include < alibabacloud/oss/Export.h>
21+ #include < alibabacloud/oss/http/HttpRequest.h>
22+
23+ namespace AlibabaCloud
24+ {
25+ namespace OSS
26+ {
27+ class ALIBABACLOUD_OSS_EXPORT HttpInterceptor
28+ {
29+ public:
30+ HttpInterceptor () = default ;
31+ virtual ~HttpInterceptor () = default ;
32+ virtual void preSendRequest (void *handler, const std::shared_ptr<HttpRequest> &request) = 0;
33+ };
34+ }
35+ }
Original file line number Diff line number Diff line change @@ -118,7 +118,8 @@ ClientConfiguration::ClientConfiguration() :
118118 httpClient(nullptr ),
119119 isPathStyle(false ),
120120 isVerifyObjectStrict(true ),
121- signatureVersion(SignatureVersionType::V1)
121+ signatureVersion(SignatureVersionType::V1),
122+ httpInterceptor(nullptr )
122123{
123124
124125}
Original file line number Diff line number Diff line change @@ -418,7 +418,8 @@ CurlHttpClient::CurlHttpClient(const ClientConfiguration &configuration) :
418418 caFile_(configuration.caFile),
419419 networkInterface_(configuration.networkInterface),
420420 sendRateLimiter_(configuration.sendRateLimiter),
421- recvRateLimiter_(configuration.recvRateLimiter)
421+ recvRateLimiter_(configuration.recvRateLimiter),
422+ httpInterceptor_(configuration.httpInterceptor)
422423{
423424}
424425
@@ -567,6 +568,10 @@ std::shared_ptr<HttpResponse> CurlHttpClient::makeRequest(const std::shared_ptr<
567568 curl_easy_setopt (curl, CURLOPT_MAX_RECV_SPEED_LARGE, speed);
568569 }
569570
571+ if (httpInterceptor_ != nullptr ) {
572+ httpInterceptor_->preSendRequest (curl, request);
573+ }
574+
570575 CURLcode res = curl_easy_perform (curl);
571576 long response_code= 0 ;
572577 curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &response_code);
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ namespace OSS
5252 public:
5353 std::shared_ptr<RateLimiter> sendRateLimiter_;
5454 std::shared_ptr<RateLimiter> recvRateLimiter_;
55+ std::shared_ptr<HttpInterceptor> httpInterceptor_;
5556 };
5657}
5758}
You can’t perform that action at this time.
0 commit comments