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; |