From abf89d32d9434f3b3eed74dc2b61f2434ea51fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D1=88=D0=B5=20=D0=B2=D0=B0=D0=BC=20=D1=81=20?= =?UTF-8?q?=D0=BA=D0=B8=D1=81=D1=82=D0=BE=D1=87=D0=BA=D0=BE=D0=B9?= Date: Fri, 1 Sep 2017 09:26:14 +0100 Subject: [PATCH] Make C ws client work with Go PUBLISHED_FROM=263553121b992ec0f66b0275b4e10f4176281812 --- mongoose.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index 402cd6ff..b1278dfe 100644 --- a/mongoose.c +++ b/mongoose.c @@ -8036,7 +8036,7 @@ struct mg_connection *mg_connect_http_opt( mg_printf(nc, "%s %.*s HTTP/1.1\r\nHost: %.*s\r\nContent-Length: %" SIZE_T_FMT "\r\n%.*s%s\r\n%s", (post_data[0] == '\0' ? "GET" : "POST"), (int) path.len, path.p, - (int) host.len, host.p, strlen(post_data), (int) auth.len, + (int) (path.p - host.p), host.p, strlen(post_data), (int) auth.len, (auth.buf == NULL ? "" : auth.buf), extra_headers, post_data); mbuf_free(&auth); @@ -9511,7 +9511,8 @@ void mg_send_websocket_handshake3v(struct mg_connection *nc, /* TODO(mkm): take default hostname from http proto data if host == NULL */ if (host.len > 0) { - mg_printf(nc, "Host: %.*s\r\n", (int) host.len, host.p); + int host_len = (int) (path.p - host.p); /* Account for possible :PORT */ + mg_printf(nc, "Host: %.*s\r\n", host_len, host.p); } if (protocol.len > 0) { mg_printf(nc, "Sec-WebSocket-Protocol: %.*s\r\n", (int) protocol.len,