/*---------------------------------------------------------------------------*/ static int input_pt(struct http_socket *s, const uint8_t *inputptr, int inputdatalen) { int i; PT_BEGIN(&s->pt); /* Parse the header */ s->header_received = 0; do { for(i = 0; i < inputdatalen; i++) { if(!PT_SCHEDULE(parse_header_byte(s, inputptr[i]))) { s->header_received = 1; break; } } inputdatalen -= i; inputptr += i; if(s->header_received == 0) { /* If we have not yet received the full header, we wait for the next packet to arrive. */ PT_YIELD(&s->pt); } } while(s->header_received == 0); do { /* Receive the data */ call_callback(s, HTTP_SOCKET_DATA, inputptr, inputdatalen); PT_YIELD(&s->pt); } while(inputdatalen > 0); PT_END(&s->pt); }
/*---------------------------------------------------------------------------*/ static int input_pt(struct http_socket *s, const uint8_t *inputptr, int inputdatalen) { int i; PT_BEGIN(&s->pt); /* Parse the header */ s->header_received = 0; do { for(i = 0; i < inputdatalen; i++) { if(!PT_SCHEDULE(parse_header_byte(s, inputptr[i]))) { s->header_received = 1; break; } } inputdatalen -= i; inputptr += i; if(s->header_received == 0) { /* If we have not yet received the full header, we wait for the next packet to arrive. */ PT_YIELD(&s->pt); } } while(s->header_received == 0); s->bodylen = 0; do { /* Receive the data */ call_callback(s, HTTP_SOCKET_DATA, inputptr, inputdatalen); /* Close the connection if the expected content length has been received */ if(s->header.content_length >= 0 && s->bodylen < s->header.content_length) { s->bodylen += inputdatalen; if(s->bodylen >= s->header.content_length) { tcp_socket_close(&s->s); } } PT_YIELD(&s->pt); } while(inputdatalen > 0); PT_END(&s->pt); }