mirror of
https://github.com/sheumann/NetDisk.git
synced 2024-11-27 19:49:38 +00:00
HTTP header parsing tweaks.
These should slightly improve performance.
This commit is contained in:
parent
21465b7f7a
commit
65c6c68936
25
http.c
25
http.c
@ -4,6 +4,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <tcpip.h>
|
#include <tcpip.h>
|
||||||
#include <misctool.h>
|
#include <misctool.h>
|
||||||
@ -223,11 +224,11 @@ netRetry:
|
|||||||
goto errorReturn;
|
goto errorReturn;
|
||||||
response++;
|
response++;
|
||||||
|
|
||||||
while (*response != '\r' && response < responseEnd)
|
while (*response != '\r')
|
||||||
response++;
|
response++;
|
||||||
response++;
|
response++;
|
||||||
|
|
||||||
if (*response != '\n' && response < responseEnd)
|
if (*response != '\n')
|
||||||
goto errorReturn;
|
goto errorReturn;
|
||||||
response++;
|
response++;
|
||||||
|
|
||||||
@ -270,7 +271,7 @@ netRetry:
|
|||||||
|
|
||||||
result = UNSUPPORTED_HEADER_VALUE;
|
result = UNSUPPORTED_HEADER_VALUE;
|
||||||
|
|
||||||
while (response < responseEnd - 2) {
|
while (response < responseEnd - 4) {
|
||||||
enum ResponseHeader header = UNKNOWN_HEADER;
|
enum ResponseHeader header = UNKNOWN_HEADER;
|
||||||
|
|
||||||
if (wantRedirect) {
|
if (wantRedirect) {
|
||||||
@ -278,23 +279,29 @@ netRetry:
|
|||||||
response += 9;
|
response += 9;
|
||||||
header = LOCATION;
|
header = LOCATION;
|
||||||
}
|
}
|
||||||
} else {
|
} else switch (_toupper(*response)) {
|
||||||
|
case 'C':
|
||||||
if (strncasecmp(response, "Content-Range:", 14) == 0) {
|
if (strncasecmp(response, "Content-Range:", 14) == 0) {
|
||||||
response += 14;
|
response += 14;
|
||||||
header = CONTENT_RANGE;
|
header = CONTENT_RANGE;
|
||||||
} else if (strncasecmp(response, "Content-Length:", 15) == 0) {
|
} else if (strncasecmp(response, "Content-Length:", 15) == 0) {
|
||||||
response += 15;
|
response += 15;
|
||||||
header = CONTENT_LENGTH;
|
header = CONTENT_LENGTH;
|
||||||
} else if (strncasecmp(response, "Transfer-Encoding:", 18) == 0) {
|
|
||||||
response += 18;
|
|
||||||
header = TRANSFER_ENCODING;
|
|
||||||
} else if (strncasecmp(response, "Content-Encoding:", 17) == 0) {
|
} else if (strncasecmp(response, "Content-Encoding:", 17) == 0) {
|
||||||
response += 17;
|
response += 17;
|
||||||
header = CONTENT_ENCODING;
|
header = CONTENT_ENCODING;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'T':
|
||||||
|
if (strncasecmp(response, "Transfer-Encoding:", 18) == 0) {
|
||||||
|
response += 18;
|
||||||
|
header = TRANSFER_ENCODING;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((*response == ' ' || *response == '\t') && response < responseEnd)
|
while (*response == ' ' || *response == '\t')
|
||||||
response++;
|
response++;
|
||||||
|
|
||||||
switch (header) {
|
switch (header) {
|
||||||
@ -369,7 +376,7 @@ netRetry:
|
|||||||
/* Unknown headers: ignored */
|
/* Unknown headers: ignored */
|
||||||
case UNKNOWN_HEADER:
|
case UNKNOWN_HEADER:
|
||||||
default:
|
default:
|
||||||
while (*response != '\r' && response < responseEnd)
|
while (*response != '\r')
|
||||||
response++;
|
response++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user