Skip to content

Commit

Permalink
host field in HTTP header is no longer limited to 31 charcters (nodem…
Browse files Browse the repository at this point in the history
…cu#2205)

* host field in HTTP header is no longer limited to 31 charcters
* added description for magic values
  • Loading branch information
paweljasinski authored and marcelstoer committed Dec 24, 2017
1 parent 443e821 commit d8d7381
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/http/httpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,23 @@ static void ICACHE_FLASH_ATTR http_connect_callback( void * arg )
ua_len = strlen(ua_header);
}

char host_header[32] = "";
char * host_header = "";
int host_len = 0;
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)
#ifdef CLIENT_SSL_ENABLE
|| ((req->port == 443) && ( req->secure ))
#endif
)
{
host_header = alloca(max_header_len);
os_sprintf( host_header, "Host: %s\r\n", req->hostname );
}
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 );
}
host_len = strlen(host_header);
Expand Down

0 comments on commit d8d7381

Please sign in to comment.