summaryrefslogtreecommitdiff
path: root/source/sv_http.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2007-12-23 20:46:54 +0000
committerAndrey Nazarov <skuller@skuller.net>2007-12-23 20:46:54 +0000
commitf1be065ea60bbb97f6d21477fc45e49bbb29cd71 (patch)
tree8807bcb0590abc3e1472a3b977c3d112498acd23 /source/sv_http.c
parentb1fa1be8b67e6d34a3d11fe4bfb9cd27191e2b28 (diff)
Added support for parsing anticheat cvars.txt and hashes.txt.
Properly parse multiple AC server messages received at once. Added `--enable-anticheat' option to configure script.
Diffstat (limited to 'source/sv_http.c')
-rw-r--r--source/sv_http.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/source/sv_http.c b/source/sv_http.c
index d3c9d72..a7da6f2 100644
--- a/source/sv_http.c
+++ b/source/sv_http.c
@@ -249,16 +249,15 @@ void SV_HttpWrite( tcpClient_t *client, void *data, int length ) {
#if USE_ZLIB
if( client->z.state ) {
z_streamp z = &client->z;
- int param;
+ int param = Z_NO_FLUSH;
- z->next_in = data;
- z->avail_in = length;
-
- param = Z_NO_FLUSH;
if( client->noflush > 120 ) {
param = Z_SYNC_FLUSH;
}
+ z->next_in = data;
+ z->avail_in = length;
+
while( z->avail_in ) {
data = FIFO_Reserve( fifo, &length );
if( !length ) {
@@ -275,7 +274,7 @@ void SV_HttpWrite( tcpClient_t *client, void *data, int length ) {
}
length -= z->avail_out;
- if( length ) {
+ if( length > 0 ) {
FIFO_Commit( fifo, length );
client->noflush = 0;
}
@@ -283,7 +282,7 @@ void SV_HttpWrite( tcpClient_t *client, void *data, int length ) {
return;
}
#else
- if( FIFO_Write( fifo, data, length ) != length ) {
+ if( !FIFO_TryWrite( fifo, data, length ) ) {
SV_HttpDrop( client, "overflowed" );
}
#endif
@@ -500,7 +499,7 @@ static qboolean SV_HttpParseRequest( tcpClient_t *client ) {
if( !client->method ) {
// parse request line
- token = COM_SimpleParse( &line );
+ token = COM_SimpleParse( &line, NULL );
if( !token[0] ) {
continue; // ignore empty lines
}
@@ -518,7 +517,7 @@ static qboolean SV_HttpParseRequest( tcpClient_t *client ) {
}
// parse URI
- token = COM_SimpleParse( &line );
+ token = COM_SimpleParse( &line, NULL );
if( !Q_stricmpn( token, "http://", 7 ) ) {
p = strchr( token + 7, '/' );
if( !p ) {
@@ -537,7 +536,7 @@ static qboolean SV_HttpParseRequest( tcpClient_t *client ) {
}
// parse version
- token = COM_SimpleParse( &line );
+ token = COM_SimpleParse( &line, NULL );
if( strncmp( token, "HTTP/", 5 ) ) {
SV_HttpReject( "400 Bad Request", NULL );
break;
@@ -553,7 +552,7 @@ static qboolean SV_HttpParseRequest( tcpClient_t *client ) {
break;
}
} else {
- token = COM_SimpleParse( &line );
+ token = COM_SimpleParse( &line, NULL );
if( !token[0] ) {
if( !client->host || !client->resource ) {
SV_HttpReject( "400 Bad Request", NULL );
@@ -571,7 +570,7 @@ static qboolean SV_HttpParseRequest( tcpClient_t *client ) {
*p = 0;
Q_strlwr( key );
- token = COM_SimpleParse( &line );
+ token = COM_SimpleParse( &line, NULL );
if( !strcmp( key, "host" ) ) {
if( !client->host ) {
client->host = SV_CopyString( token );
@@ -583,7 +582,7 @@ static qboolean SV_HttpParseRequest( tcpClient_t *client ) {
if( Q_stricmp( token, "Basic" ) ) {
continue;
}
- token = COM_SimpleParse( &line );
+ token = COM_SimpleParse( &line, NULL );
if( Q_Decode64( key, token, sizeof( key ) ) == -1 ) {
continue;
}