Skip to content
Snippets Groups Projects
Commit 5574b452 authored by Dimitri Papadopoulos's avatar Dimitri Papadopoulos Committed by Dimitri Papadopoulos Orfanos
Browse files

Code review and cleanup of http_receive()

Improve readabilty by moving conditionals that operate on 'n'
right after assignment of 'n'. The conditional at the end of
the loop:
	while (n > = 0)
has been replaced by this conditional:
	if (n < = 0)
and this one that triggers a tight 2nd loop:
	if (n == ERR_SSL_AGAIN) ⇔ if (n == 0)

The new codes *returns from the function* with ERR_HTTP_SSL upon:
	if (n < 0)
The previous code would only *leave the loop* upon:
	if (n < 0)
and then return from the function with ERR_HTTP_SSL only upon:
	if (!header)
Therefore SSL violations were silently ignored after reading
the header and while reading the body of the HTTP response.

Increase the HTTP buffer capacity when needed. You never know.
The previous size of 32 KB used to work well from 2015 to 2020.
In 2020 a case was reported where 32 KB were not enough anymore
and we increased the buffer size to 64 KB. Someday 64 KB might
not be enough either. Yet in most cases 32 KB are more than
enough. So start with 32 KB and increase well beyond 64 KB if
needed, instead of bailing out with ERR_HTTP_SSL.

These changes will help introduce 3rd party HTTP parsing code
if we decide to go that way.
parent 8b0c235b
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment