engine: network: set HTTP buffer to 8kb on all systems, without depending on random constant like BUFSIZ

This commit is contained in:
Alibek Omarov 2023-11-26 23:19:49 +03:00
parent 68377435c8
commit 7051b844ff

View File

@ -2200,6 +2200,8 @@ HTTP downloader
=================================================
*/
#define MAX_HTTP_BUFFER_SIZE (BIT( 13 ))
typedef struct httpserver_s
{
char host[256];
@ -2240,7 +2242,7 @@ typedef struct httpfile_s
qboolean process;
// query or response
char buf[BUFSIZ+1];
char buf[MAX_HTTP_BUFFER_SIZE+1];
int header_size, query_length, bytes_sent;
} httpfile_t;
@ -2385,18 +2387,18 @@ process incoming data
*/
static qboolean HTTP_ProcessStream( httpfile_t *curfile )
{
char buf[BUFSIZ+1];
char buf[sizeof( curfile->buf )];
char *begin = 0;
int res;
if( curfile->header_size >= BUFSIZ )
if( curfile->header_size >= sizeof( buf ))
{
Con_Reportf( S_ERROR "Header to big\n");
Con_Reportf( S_ERROR "Header too big, the size is %s\n", curfile->header_size );
HTTP_FreeFile( curfile, true );
return false;
}
while( ( res = recv( curfile->socket, buf, BUFSIZ - curfile->header_size, 0 )) > 0) // if we got there, we are receiving data
while( ( res = recv( curfile->socket, buf, sizeof( buf ) - curfile->header_size, 0 )) > 0) // if we got there, we are receiving data
{
curfile->blocktime = 0;