Browse Source

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
master
Georg Hopp 14 years ago
parent
commit
1af8b32fdf
  1. 2
      src/cbuf/skip_non_alpha.c
  2. 4
      src/http/parser/body.c
  3. 23
      src/http/parser/parse.c

2
src/cbuf/skip_non_alpha.c

@ -27,7 +27,7 @@
void
cbufSkipNonAlpha(Cbuf this)
{
while(0 > this->bused && isalpha(*cbufGetRead(this)))
while(0 < this->bused && !isalpha(*cbufGetRead(this)))
cbufIncRead(this, 1);
}

4
src/http/parser/body.c

@ -28,7 +28,7 @@
#include "http/parser.h"
#include "cbuf.h"
#define MAX(a,b) (((a) > (b))? (a) : (b))
#define MIN(a,b) (((a) < (b))? (a) : (b))
size_t
httpParserBody(HttpParser this, const char * buf, size_t nbuf)
@ -37,7 +37,7 @@ httpParserBody(HttpParser this, const char * buf, size_t nbuf)
HttpMessage current = this->current;
if (current->dbody < current->nbody) {
len = MAX(current->nbody - current->dbody, nbuf);
len = MIN(current->nbody - current->dbody, nbuf);
memcpy(current->body, buf, len);

23
src/http/parser/parse.c

@ -120,23 +120,24 @@ httpParserParse(void * _this, Stream st)
break;
case HTTP_MESSAGE_HEADERS_DONE:
{
cbufIncRead(
this->buffer,
httpParserBody(
this,
cbufGetRead(this->buffer),
this->buffer->bused));
if (this->current->dbody == this->current->nbody) {
this->state = HTTP_MESSAGE_DONE;
break;
}
if (cbufIsEmpty(this->buffer)) {
cbufRelease(this->buffer);
this->ourLock = FALSE;
cont = 0;
break;
}
if (this->current->dbody == this->current->nbody) {
this->state = HTTP_MESSAGE_DONE;
}
}
cbufIncRead(
this->buffer,
httpParserBody(
this,
cbufGetRead(this->buffer),
this->buffer->bused));
break;
case HTTP_MESSAGE_DONE:

Loading…
Cancel
Save