Skip to content

Commit 03a5cf8

Browse files
authored
default port (#617)
1 parent c197a18 commit 03a5cf8

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

include/cinatra/coro_http_client.hpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -1546,20 +1546,21 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
15461546
if (!proxy_host_.empty() && !proxy_port_.empty()) {
15471547
if (!proxy_request_uri_.empty())
15481548
proxy_request_uri_.clear();
1549-
if (u.get_port() == "http") {
1550-
proxy_request_uri_ += "http://" + u.get_host() + ":";
1551-
proxy_request_uri_ += "80";
1549+
if (u.get_port() == "80") {
1550+
proxy_request_uri_.append("http://").append(u.get_host()).append(":80");
15521551
}
1553-
else if (u.get_port() == "https") {
1554-
proxy_request_uri_ += "https://" + u.get_host() + ":";
1555-
proxy_request_uri_ += "443";
1552+
else if (u.get_port() == "443") {
1553+
proxy_request_uri_.append("https://")
1554+
.append(u.get_host())
1555+
.append(":443");
15561556
}
15571557
else {
15581558
// all be http
1559-
proxy_request_uri_ += "http://" + u.get_host() + ":";
1560-
proxy_request_uri_ += u.get_port();
1559+
proxy_request_uri_.append("http://")
1560+
.append(u.get_host())
1561+
.append(u.get_port());
15611562
}
1562-
proxy_request_uri_ += u.get_path();
1563+
proxy_request_uri_.append(u.get_path());
15631564
u.path = std::string_view(proxy_request_uri_);
15641565
}
15651566
}

include/cinatra/uri.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,15 @@ class uri_t {
232232
std::string port_str;
233233
if (is_ssl) {
234234
if (port.empty()) {
235-
port_str = "https";
235+
port_str = "443";
236236
}
237237
else {
238238
port_str = std::string(port);
239239
}
240240
}
241241
else {
242242
if (port.empty()) {
243-
port_str = "http";
243+
port_str = "80";
244244
}
245245
else {
246246
port_str = std::string(port);

include/cinatra/version.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
// CINATRA_VERSION % 100 is the sub-minor version
66
// CINATRA_VERSION / 100 % 1000 is the minor version
77
// CINATRA_VERSION / 100000 is the major version
8-
#define CINATRA_VERSION 901 // 0.9.1
8+
#define CINATRA_VERSION 902 // 0.9.2

lang/coro_http_client_introduction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ async_simple::coro::Lazy<void> test_async_client() {
252252
// 通过重连复用client1
253253
r = async_simple::coro::syncAwait(client1.connect("http://cn.bing.com"));
254254
CHECK(client1.get_host() == "cn.bing.com");
255-
CHECK(client1.get_port() == "http");
255+
CHECK(client1.get_port() == "80");
256256
CHECK(r.status == 200);
257257
```
258258

tests/test_cinatra.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ TEST_CASE("test coro_http_client async_http_connect") {
753753

754754
r = async_simple::coro::syncAwait(client1.connect("http://cn.bing.com"));
755755
CHECK(client1.get_host() == "cn.bing.com");
756-
CHECK(client1.get_port() == "http");
756+
CHECK(client1.get_port() == "80");
757757
CHECK(r.status >= 200);
758758

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

0 commit comments

Comments
 (0)