Browse Source

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

pull/2/head
Alibek Omarov 1 year ago
parent
commit
7051b844ff
  1. 12
      engine/common/net_ws.c

12
engine/common/net_ws.c

@ -2200,6 +2200,8 @@ HTTP downloader @@ -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 @@ -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 @@ -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;

Loading…
Cancel
Save