Skip to content

Commit 64fe98c

Browse files
committed
Fixup conditionally prepending host_port
1 parent b7c7561 commit 64fe98c

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

lib/src/http_wasm.cc

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ class HTTPWasmClient : public HTTPClient {
2020

2121
unique_ptr<HTTPResponse> Get(GetRequestInfo &info) override {
2222
// clang-format off
23+
2324
unique_ptr<HTTPResponse> res;
2425

25-
string path = host_port + info.url;
26-
path = info.url;
26+
string path = info.url;
27+
if (path[0] == '/') path = host_port + info.url;
28+
2729
if (!web::experimental_s3_tables_global_proxy.empty()) {
2830
if (info.url.rfind(web::experimental_s3_tables_global_proxy, 0) != 0) {
2931
auto id_table = path.find("--table-s3.s3.");
@@ -165,8 +167,9 @@ class HTTPWasmClient : public HTTPClient {
165167
unique_ptr<HTTPResponse> Head(HeadRequestInfo &info) override {
166168
unique_ptr<HTTPResponse> res;
167169

168-
string path = host_port + info.url;
169-
path = info.url;
170+
string path = info.url;
171+
if (path[0] == '/') path = host_port + info.url;
172+
170173
if (!web::experimental_s3_tables_global_proxy.empty()) {
171174
if (info.url.rfind(web::experimental_s3_tables_global_proxy, 0) != 0) {
172175
auto id_table = path.find("--table-s3.s3.");
@@ -405,8 +408,9 @@ res->headers.Insert(head, tail);
405408
unique_ptr<HTTPResponse> Post(PostRequestInfo &info) override {
406409
unique_ptr<HTTPResponse> res;
407410

408-
string path = host_port + info.url;
409-
path = info.url;
411+
string path = info.url;
412+
if (path[0] == '/') path = host_port + info.url;
413+
410414
if (!web::experimental_s3_tables_global_proxy.empty()) {
411415
if (info.url.rfind(web::experimental_s3_tables_global_proxy, 0) != 0) {
412416
auto id_table = path.find("--table-s3.s3.");
@@ -559,8 +563,9 @@ res->headers.Insert(head, tail);
559563
unique_ptr<HTTPResponse> Put(PutRequestInfo &info) override {
560564
unique_ptr<HTTPResponse> res;
561565

562-
string path = host_port + info.url;
563-
path = info.url;
566+
string path = info.url;
567+
if (path[0] == '/') path = host_port + info.url;
568+
564569
if (!web::experimental_s3_tables_global_proxy.empty()) {
565570
if (info.url.rfind(web::experimental_s3_tables_global_proxy, 0) != 0) {
566571
auto id_table = path.find("--table-s3.s3.");
@@ -713,8 +718,8 @@ res->headers.Insert(head, tail);
713718
unique_ptr<HTTPResponse> Delete(DeleteRequestInfo &info) override {
714719
unique_ptr<HTTPResponse> res;
715720

716-
string path = host_port + info.url;
717-
path = info.url;
721+
string path = info.url;
722+
if (path[0] == '/') path = host_port + info.url;
718723

719724
if (!web::experimental_s3_tables_global_proxy.empty()) {
720725
if (info.url.rfind(web::experimental_s3_tables_global_proxy, 0) != 0) {

0 commit comments

Comments
 (0)