From 03ca795bd6c163eaed116a129ec4d1a53833700c Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Tue, 31 May 2016 17:11:59 -0300 Subject: [PATCH] fix ipv6 http socket host handling as in RFC2732 --- core/net/http-socket/http-socket.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/net/http-socket/http-socket.c b/core/net/http-socket/http-socket.c index 758c1473e..1e5ebbb27 100644 --- a/core/net/http-socket/http-socket.c +++ b/core/net/http-socket/http-socket.c @@ -412,7 +412,15 @@ event(struct tcp_socket *tcps, void *ptr, tcp_socket_send_str(tcps, " HTTP/1.1\r\n"); tcp_socket_send_str(tcps, "Connection: close\r\n"); tcp_socket_send_str(tcps, "Host: "); + /* If we have IPv6 host, add the '[' and the ']' characters + to the host. As in rfc2732. */ + if (strchr(host, ':')) { + tcp_socket_send_str(tcps, "["); + } tcp_socket_send_str(tcps, host); + if (strchr(host, ':')) { + tcp_socket_send_str(tcps, "]"); + } tcp_socket_send_str(tcps, "\r\n"); if(s->postdata != NULL) { if(s->content_type) {