Skip to content

Commit 4eac522

Browse files
committed
Added a some extra options for the client and the request; removed some files I added.
1 parent 07e1e8e commit 4eac522

11 files changed

+42
-646
lines changed

http/src/network/http/v2/client_options.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,20 @@ namespace v2 {
7979
return timeout_;
8080
}
8181

82+
client_options &openssl_certificate_path(std::string path) {
83+
openssl_certificate_paths_.emplace_back(std::move(path));
84+
return *this;
85+
}
86+
8287
std::vector<std::string> openssl_certificate_paths() const {
8388
return openssl_certificate_paths_;
8489
}
8590

91+
client_options &openssl_verify_path(std::string path) {
92+
openssl_verify_paths_.emplace_back(std::move(path));
93+
return *this;
94+
}
95+
8696
std::vector<std::string> openssl_verify_paths() const {
8797
return openssl_verify_paths_;
8898
}

http/src/network/http/v2/request_options.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ namespace v2 {
2020
constexpr request_options()
2121
: resolve_timeout_(30000)
2222
, read_timeout_(30000)
23-
, total_timeout_(30000) { }
23+
, total_timeout_(30000)
24+
, max_redirects_(10) { }
2425

2526
request_options(request_options const &) = default;
2627
request_options(request_options &&) = default;
@@ -63,11 +64,21 @@ namespace v2 {
6364
return total_timeout_;
6465
}
6566

67+
request_options &max_redirects(int max_redirects) noexcept {
68+
max_redirects_ = max_redirects;
69+
return *this;
70+
}
71+
72+
constexpr int max_redirects() const noexcept {
73+
return max_redirects_;
74+
}
75+
6676
private:
6777

6878
std::uint64_t resolve_timeout_;
6979
std::uint64_t read_timeout_;
7080
std::uint64_t total_timeout_;
81+
int max_redirects_;
7182

7283
};
7384
} // namespace v2

http/test/client/v2/request_options_test.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

http/test/v2/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ foreach(test ${CPP-NETLIB_CLIENT_TESTS})
2727
${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-v2-${test})
2828

2929
endforeach(test)
30+
31+
add_subdirectory(client)

http/test/v2/client/client_options_test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,15 @@ TEST(client_options_test, set_option_use_proxy) {
4848
opts.use_proxy(true);
4949
ASSERT_TRUE(opts.use_proxy());
5050
}
51+
52+
TEST(client_options_test, set_option_openssl_certificate_path) {
53+
network::http::v2::client_options opts;
54+
opts.openssl_certificate_path("openssl_certificate");
55+
ASSERT_EQ(std::vector<std::string>{"openssl_certificate"}, opts.openssl_certificate_paths());
56+
}
57+
58+
TEST(client_options_test, set_option_openssl_verify_path) {
59+
network::http::v2::client_options opts;
60+
opts.openssl_verify_path("openssl_verify");
61+
ASSERT_EQ(std::vector<std::string>{"openssl_verify"}, opts.openssl_verify_paths());
62+
}

http/test/v2/client/regression/request_base_test.cpp

Lines changed: 0 additions & 67 deletions
This file was deleted.

http/test/v2/client/regression/request_incremental_parser_test.cpp

Lines changed: 0 additions & 142 deletions
This file was deleted.

0 commit comments

Comments
 (0)