Revert "host field in HTTP header is no longer limited to 31 charcters (#2205)" (#2208)

This reverts commit d8d7381a38.
This commit is contained in:
Marcel Stör 2017-12-24 23:22:03 +01:00 committed by GitHub
parent d8d7381a38
commit 5073c199c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 4 deletions

View File

@ -215,23 +215,20 @@ static void ICACHE_FLASH_ATTR http_connect_callback( void * arg )
ua_len = strlen(ua_header); ua_len = strlen(ua_header);
} }
char * host_header = ""; char host_header[32] = "";
int host_len = 0; int host_len = 0;
if ( os_strstr( req->headers, "Host:" ) == NULL && os_strstr( req->headers, "host:" ) == NULL) if ( os_strstr( req->headers, "Host:" ) == NULL && os_strstr( req->headers, "host:" ) == NULL)
{ {
int max_header_len = 9 + strlen(req->hostname); // 9 is fixed size of "Host:[space][cr][lf]\0"
if ((req->port == 80) if ((req->port == 80)
#ifdef CLIENT_SSL_ENABLE #ifdef CLIENT_SSL_ENABLE
|| ((req->port == 443) && ( req->secure )) || ((req->port == 443) && ( req->secure ))
#endif #endif
) )
{ {
host_header = alloca(max_header_len);
os_sprintf( host_header, "Host: %s\r\n", req->hostname ); os_sprintf( host_header, "Host: %s\r\n", req->hostname );
} }
else else
{ {
host_header = alloca(max_header_len + 6); // 6 is worst case of ":port" where port is maximum 5 digits
os_sprintf( host_header, "Host: %s:%d\r\n", req->hostname, req->port ); os_sprintf( host_header, "Host: %s:%d\r\n", req->hostname, req->port );
} }
host_len = strlen(host_header); host_len = strlen(host_header);