Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default port #617

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading