fix ipv6 http socket host handling as in RFC2732

This commit is contained in:
Marco Casaroli 2016-05-31 17:11:59 -03:00
parent 2ad6d18c9d
commit 03ca795bd6

View File

@ -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, " HTTP/1.1\r\n");
tcp_socket_send_str(tcps, "Connection: close\r\n"); tcp_socket_send_str(tcps, "Connection: close\r\n");
tcp_socket_send_str(tcps, "Host: "); 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); tcp_socket_send_str(tcps, host);
if (strchr(host, ':')) {
tcp_socket_send_str(tcps, "]");
}
tcp_socket_send_str(tcps, "\r\n"); tcp_socket_send_str(tcps, "\r\n");
if(s->postdata != NULL) { if(s->postdata != NULL) {
if(s->content_type) { if(s->content_type) {