Commit 1af8b32fdf1588b2533eb311d1c36b1d2398902b
1 parent
f1215c67
Some fixes:
- skipNonAlpha now really skips NON alpha chars - parserBody now reads the MIN of want to what's available - changed the order in body read...an 0 nbody leads to immediate completion, than the first check is if the buffer is empty and only if it's not data is read. fixes #20
Showing
3 changed files
with
19 additions
and
18 deletions
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | #include "http/parser.h" |
| 29 | 29 | #include "cbuf.h" |
| 30 | 30 | |
| 31 | -#define MAX(a,b) (((a) > (b))? (a) : (b)) | |
| 31 | +#define MIN(a,b) (((a) < (b))? (a) : (b)) | |
| 32 | 32 | |
| 33 | 33 | size_t |
| 34 | 34 | httpParserBody(HttpParser this, const char * buf, size_t nbuf) |
| ... | ... | @@ -37,7 +37,7 @@ httpParserBody(HttpParser this, const char * buf, size_t nbuf) |
| 37 | 37 | HttpMessage current = this->current; |
| 38 | 38 | |
| 39 | 39 | if (current->dbody < current->nbody) { |
| 40 | - len = MAX(current->nbody - current->dbody, nbuf); | |
| 40 | + len = MIN(current->nbody - current->dbody, nbuf); | |
| 41 | 41 | |
| 42 | 42 | memcpy(current->body, buf, len); |
| 43 | 43 | ... | ... |
| ... | ... | @@ -120,23 +120,24 @@ httpParserParse(void * _this, Stream st) |
| 120 | 120 | break; |
| 121 | 121 | |
| 122 | 122 | case HTTP_MESSAGE_HEADERS_DONE: |
| 123 | - { | |
| 124 | - cbufIncRead( | |
| 125 | - this->buffer, | |
| 126 | - httpParserBody( | |
| 127 | - this, | |
| 128 | - cbufGetRead(this->buffer), | |
| 129 | - this->buffer->bused)); | |
| 130 | - | |
| 131 | - if (cbufIsEmpty(this->buffer)) { | |
| 132 | - cbufRelease(this->buffer); | |
| 133 | - this->ourLock = FALSE; | |
| 134 | - } | |
| 123 | + if (this->current->dbody == this->current->nbody) { | |
| 124 | + this->state = HTTP_MESSAGE_DONE; | |
| 125 | + break; | |
| 126 | + } | |
| 135 | 127 | |
| 136 | - if (this->current->dbody == this->current->nbody) { | |
| 137 | - this->state = HTTP_MESSAGE_DONE; | |
| 138 | - } | |
| 128 | + if (cbufIsEmpty(this->buffer)) { | |
| 129 | + cbufRelease(this->buffer); | |
| 130 | + this->ourLock = FALSE; | |
| 131 | + cont = 0; | |
| 132 | + break; | |
| 139 | 133 | } |
| 134 | + | |
| 135 | + cbufIncRead( | |
| 136 | + this->buffer, | |
| 137 | + httpParserBody( | |
| 138 | + this, | |
| 139 | + cbufGetRead(this->buffer), | |
| 140 | + this->buffer->bused)); | |
| 140 | 141 | break; |
| 141 | 142 | |
| 142 | 143 | case HTTP_MESSAGE_DONE: | ... | ... |
Please
register
or
login
to post a comment