Skip to content

Commit

Permalink
fix ssl option (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos authored May 31, 2024
1 parent 9c7cffe commit 9a7b36a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/ylt/standalone/cinatra/coro_http_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,12 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
bool no_schema = !has_schema(uri);
std::string append_uri;
if (no_schema) {
append_uri.append("http://").append(uri);
#ifdef CINATRA_ENABLE_SSL
if (is_ssl_schema_)
append_uri.append("https://").append(uri);
else
#endif
append_uri.append("http://").append(uri);
}

auto [ok, u] = handle_uri(data, no_schema ? append_uri : uri);
Expand Down
11 changes: 11 additions & 0 deletions src/coro_http/examples/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,17 @@ async_simple::coro::Lazy<void> basic_usage() {
co_await client3.connect("https://www.baidu.com");
result = co_await client3.async_get("/");
assert(result.status == 200);

coro_http_client client4{};
client4.set_ssl_schema(true);
result = client4.get("www.baidu.com");
assert(result.status == 200);

coro_http_client client5{};
client5.set_ssl_schema(true);
co_await client5.connect("www.baidu.com");
result = co_await client5.async_get("/");
assert(result.status == 200);
#endif
}

Expand Down

0 comments on commit 9a7b36a

Please sign in to comment.