Merge pull request #1696 from momote-io/fixes
fix ipv6 http socket host handling as in RFC2732
This commit is contained in:
commit
8cdff8c21b
|
@ -350,6 +350,11 @@ parse_url(const char *url, char *host, uint16_t *portptr, char *path)
|
|||
}
|
||||
}
|
||||
|
||||
/* check if host is null terminated */
|
||||
if(!memchr(host, 0, MAX_HOSTLEN)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Find the port. Default is 80. */
|
||||
port = 80;
|
||||
if(*urlptr == ':') {
|
||||
|
@ -413,7 +418,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(memchr(host, ':', MAX_HOSTLEN)) {
|
||||
tcp_socket_send_str(tcps, "[");
|
||||
}
|
||||
tcp_socket_send_str(tcps, host);
|
||||
if(memchr(host, ':', MAX_HOSTLEN)) {
|
||||
tcp_socket_send_str(tcps, "]");
|
||||
}
|
||||
tcp_socket_send_str(tcps, "\r\n");
|
||||
if(s->postdata != NULL) {
|
||||
if(s->content_type) {
|
||||
|
|
Loading…
Reference in a new issue