1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-07 19:13:20 +00:00

1. Fixed Control Channel bug, where host field never contained port number

2. Updated tunnels, so host field only contains port if its not a default port
This commit is contained in:
Bryan Roe
2020-03-19 23:54:16 -07:00
parent 1796d8e266
commit 46e4113814
2 changed files with 21 additions and 2 deletions

View File

@@ -1168,7 +1168,17 @@ duk_ret_t ILibDuktape_HttpStream_http_request(duk_context *ctx)
duk_swap_top(ctx, -2); // [options][headers][concat][this]
duk_push_string(ctx, ":"); // [options][headers][concat][this][:]
duk_get_prop_string(ctx, -5, "port"); // [options][headers][concat][this][:][port]
duk_call_method(ctx, 2); // [options][headers][hostname]
if ((strcmp("443", (char*)duk_to_string(ctx, -1)) == 0 && isTLS == 1) || (strcmp("80", (char*)duk_to_string(ctx, -1)) == 0 && isTLS == 0))
{
// No need to add port to host [options][headers][concat][this][:][port]
duk_pop_2(ctx); // [options][headers][concat][this]
duk_remove(ctx, -2); // [options][headers][host]
}
else
{
// Add port to host
duk_call_method(ctx, 2); // [options][headers][hostname]
}
duk_put_prop_string(ctx, -2, "Host"); // [options][headers]
duk_put_prop_string(ctx, -2, "headers"); // [options]
}