Skip to content

Commit

Permalink
default port
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Jul 22, 2024
1 parent c197a18 commit e6eebd4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
21 changes: 11 additions & 10 deletions include/cinatra/coro_http_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1546,20 +1546,21 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
if (!proxy_host_.empty() && !proxy_port_.empty()) {
if (!proxy_request_uri_.empty())
proxy_request_uri_.clear();
if (u.get_port() == "http") {
proxy_request_uri_ += "http://" + u.get_host() + ":";
proxy_request_uri_ += "80";
if (u.get_port() == "80") {
proxy_request_uri_.append("http://").append(u.get_host()).append(":80");
}
else if (u.get_port() == "https") {
proxy_request_uri_ += "https://" + u.get_host() + ":";
proxy_request_uri_ += "443";
else if (u.get_port() == "443") {
proxy_request_uri_.append("https://")
.append(u.get_host())
.append(":443");
}
else {
// all be http
proxy_request_uri_ += "http://" + u.get_host() + ":";
proxy_request_uri_ += u.get_port();
proxy_request_uri_.append("http://")
.append(u.get_host())
.append(u.get_port());
}
proxy_request_uri_ += u.get_path();
proxy_request_uri_.append(u.get_path());
u.path = std::string_view(proxy_request_uri_);
}
}
Expand Down Expand Up @@ -2424,7 +2425,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
bool enable_follow_redirect_ = false;
bool enable_timeout_ = false;
std::chrono::steady_clock::duration conn_timeout_duration_ =
std::chrono::seconds(30);
std::chrono::seconds(8);
std::chrono::steady_clock::duration req_timeout_duration_ =
std::chrono::seconds(60);
bool enable_tcp_no_delay_ = true;
Expand Down
4 changes: 2 additions & 2 deletions include/cinatra/uri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,15 @@ class uri_t {
std::string port_str;
if (is_ssl) {
if (port.empty()) {
port_str = "https";
port_str = "443";
}
else {
port_str = std::string(port);
}
}
else {
if (port.empty()) {
port_str = "http";
port_str = "80";
}
else {
port_str = std::string(port);
Expand Down
2 changes: 1 addition & 1 deletion lang/coro_http_client_introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ async_simple::coro::Lazy<void> test_async_client() {
// 通过重连复用client1
r = async_simple::coro::syncAwait(client1.connect("http://cn.bing.com"));
CHECK(client1.get_host() == "cn.bing.com");
CHECK(client1.get_port() == "http");
CHECK(client1.get_port() == "80");
CHECK(r.status == 200);
```
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cinatra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ TEST_CASE("test coro_http_client async_http_connect") {

r = async_simple::coro::syncAwait(client1.connect("http://cn.bing.com"));
CHECK(client1.get_host() == "cn.bing.com");
CHECK(client1.get_port() == "http");
CHECK(client1.get_port() == "80");
CHECK(r.status >= 200);

r = async_simple::coro::syncAwait(client1.connect("http://www.baidu.com"));
Expand Down

0 comments on commit e6eebd4

Please sign in to comment.