| 627 * >0 chunk header length |
627 * >0 chunk header length |
| 628 */ |
628 */ |
| 629 int http_stream_parse_chunk_header(char *str, int len, WSBool first, int64_t *chunklen) { |
629 int http_stream_parse_chunk_header(char *str, int len, WSBool first, int64_t *chunklen) { |
| 630 char *hdr_start = NULL; |
630 char *hdr_start = NULL; |
| 631 char *hdr_end = NULL; |
631 char *hdr_end = NULL; |
| |
632 char *chk_end = str + len; |
| 632 int i = 0; |
633 int i = 0; |
| 633 if(first) { |
634 if(first) { |
| 634 hdr_start = str; |
635 hdr_start = str; |
| 635 } else { |
636 } else { |
| 636 if(len < 3) { |
637 if(len < 3) { |
| 715 if(st->read_eof) { |
720 if(st->read_eof) { |
| 716 return 0; |
721 return 0; |
| 717 } |
722 } |
| 718 |
723 |
| 719 char *rbuf = buf; // buffer pos |
724 char *rbuf = buf; // buffer pos |
| 720 size_t rd = 0; // number of bytes read |
725 ssize_t rd = 0; // number of bytes read |
| 721 size_t rbuflen = nbytes; // number of bytes until end of buf |
726 size_t rbuflen = nbytes; // number of bytes until end of buf |
| 722 WSBool perform_io = WS_TRUE; // we do only 1 read before we abort |
727 WSBool perform_io = WS_TRUE; // we do only 1 read before we abort |
| 723 while(rd < nbytes && (perform_io || (st->max_read - st->read) > 0)) { |
728 while(rd < nbytes && (perform_io || (st->max_read - st->read) > 0)) { |
| 724 // how many bytes are available in the current chunk |
729 // how many bytes are available in the current chunk |
| 725 size_t chunk_available = st->max_read - st->read; |
730 size_t chunk_available = st->max_read - st->read; |