hwchan 7 years ago
parent
commit
fb22adcb92
1 changed files with 4 additions and 1 deletions
  1. 5
      src/http.c

5
src/http.c

@ -32,7 +32,7 @@
#include <stdlib.h> /* malloc() */ #include <stdlib.h> /* malloc() */
#include <string.h> /* strncpy() */ #include <string.h> /* strncpy() */
#include <strings.h> /* strncasecmp() */ #include <strings.h> /* strncasecmp() */
#include <ctype.h> /* isblank() */
#include <ctype.h> /* isblank(), isdigit() */
#include "http.h" #include "http.h"
#include "protocol.h" #include "protocol.h"
@ -80,6 +80,7 @@ parse_http_header(const char *data, size_t data_len, char **hostname)
/* /*
* if the user specifies the port in the request, it is included here. * if the user specifies the port in the request, it is included here.
* Host: example.com:80 * Host: example.com:80
* Host: [2001:db8::1]:8080
* so we trim off port portion * so we trim off port portion
*/ */
for (i = result - 1; i >= 0; i--) for (i = result - 1; i >= 0; i--)
@ -87,6 +88,8 @@ parse_http_header(const char *data, size_t data_len, char **hostname)
(*hostname)[i] = '\0'; (*hostname)[i] = '\0';
result = i; result = i;
break; break;
} else if (!isdigit((*hostname)[i])) {
break;
} }
return result; return result;

Loading…
Cancel
Save