1 |
/* |
/* |
2 |
http-message.c - HTTP message object |
http-message.c - HTTP message object |
3 |
Copyright (C) 2008 siliconforks.com |
Copyright (C) 2008, 2009, 2010 siliconforks.com |
4 |
|
|
5 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
6 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
431 |
skip_lws(&p); |
skip_lws(&p); |
432 |
|
|
433 |
if (*p == '\0') { |
if (*p == '\0') { |
434 |
|
/* value was empty: ignore this header??? */ |
435 |
free(name); |
free(name); |
436 |
Stream_delete(stream); |
continue; |
|
return -1; |
|
437 |
} |
} |
438 |
|
|
439 |
/* skip backward over LWS, starting from the last char in the buffer */ |
/* skip backward over LWS, starting from the last char in the buffer */ |
813 |
} |
} |
814 |
|
|
815 |
uint8_t * s = p; |
uint8_t * s = p; |
816 |
for (*bytes_read = 0; *bytes_read < capacity; (*bytes_read)++) { |
*bytes_read = 0; |
817 |
|
while (*bytes_read < capacity) { |
818 |
if (message->bytes_remaining == 0) { |
if (message->bytes_remaining == 0) { |
819 |
result = read_chunk_size_line(message); |
result = read_chunk_size_line(message); |
820 |
if (result != 0) { |
if (result != 0) { |
843 |
break; |
break; |
844 |
} |
} |
845 |
s[*bytes_read] = (uint8_t) c; |
s[*bytes_read] = (uint8_t) c; |
846 |
|
++(*bytes_read); |
847 |
message->bytes_remaining--; |
message->bytes_remaining--; |
848 |
|
|
849 |
|
if (message->bytes_remaining == 0) { |
850 |
|
// read CRLF terminating chunk |
851 |
|
result = HTTPConnection_read_octet(message->connection, &c); |
852 |
|
if (result != 0) { |
853 |
|
break; |
854 |
|
} |
855 |
|
if (c != '\r') { |
856 |
|
result = -1; |
857 |
|
message->chunked_body_state = CHUNKED_BODY_DONE; |
858 |
|
break; |
859 |
|
} |
860 |
|
result = HTTPConnection_read_octet(message->connection, &c); |
861 |
|
if (result != 0) { |
862 |
|
break; |
863 |
|
} |
864 |
|
if (c != '\n') { |
865 |
|
result = -1; |
866 |
|
message->chunked_body_state = CHUNKED_BODY_DONE; |
867 |
|
break; |
868 |
|
} |
869 |
|
} |
870 |
} |
} |
871 |
|
|
872 |
return result; |
return result; |