Skip to content

Commit

Permalink
default port (#617)
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos authored Jul 22, 2024
1 parent c197a18 commit 03a5cf8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
19 changes: 10 additions & 9 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
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 include/cinatra/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// CINATRA_VERSION % 100 is the sub-minor version
// CINATRA_VERSION / 100 % 1000 is the minor version
// CINATRA_VERSION / 100000 is the major version
#define CINATRA_VERSION 901 // 0.9.1
#define CINATRA_VERSION 902 // 0.9.2
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 03a5cf8

Please sign in to comment.