Skip to content

Commit dcce17a

Browse files
committed
Fixup conditionally prepending host_port
1 parent c3caa42 commit dcce17a

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

lib/src/http_wasm.cc

Lines changed: 19 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] == '/')
28+
path = host_port + info.url;
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,10 @@ 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] == '/')
172+
path = host_port + info.url;
173+
170174
if (!web::experimental_s3_tables_global_proxy.empty()) {
171175
if (info.url.rfind(web::experimental_s3_tables_global_proxy, 0) != 0) {
172176
auto id_table = path.find("--table-s3.s3.");
@@ -405,8 +409,10 @@ res->headers.Insert(head, tail);
405409
unique_ptr<HTTPResponse> Post(PostRequestInfo &info) override {
406410
unique_ptr<HTTPResponse> res;
407411

408-
string path = host_port + info.url;
409-
path = info.url;
412+
string path = info.url;
413+
if (path[0] == '/')
414+
path = host_port + info.url;
415+
410416
if (!web::experimental_s3_tables_global_proxy.empty()) {
411417
if (info.url.rfind(web::experimental_s3_tables_global_proxy, 0) != 0) {
412418
auto id_table = path.find("--table-s3.s3.");
@@ -559,8 +565,10 @@ res->headers.Insert(head, tail);
559565
unique_ptr<HTTPResponse> Put(PutRequestInfo &info) override {
560566
unique_ptr<HTTPResponse> res;
561567

562-
string path = host_port + info.url;
563-
path = info.url;
568+
string path = info.url;
569+
if (path[0] == '/')
570+
path = host_port + info.url;
571+
564572
if (!web::experimental_s3_tables_global_proxy.empty()) {
565573
if (info.url.rfind(web::experimental_s3_tables_global_proxy, 0) != 0) {
566574
auto id_table = path.find("--table-s3.s3.");
@@ -713,8 +721,9 @@ res->headers.Insert(head, tail);
713721
unique_ptr<HTTPResponse> Delete(DeleteRequestInfo &info) override {
714722
unique_ptr<HTTPResponse> res;
715723

716-
string path = host_port + info.url;
717-
path = info.url;
724+
string path = info.url;
725+
if (path[0] == '/')
726+
path = host_port + info.url;
718727

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

0 commit comments

Comments
 (0)