diff options
Diffstat (limited to 'src/http.c')
-rw-r--r-- | src/http.c | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -12,12 +12,9 @@ int ParseHTTPInput(char *buf, struct message *m) { char *n, *v; - /* just an empty block; go home - if ( !(*buf) ) - return 0; */ - - /* initialize message block */ + /* initialize message block memset(m, 0, sizeof (struct message) ); + */ n = buf; while ( (v = strstr(n, "=")) ) { @@ -80,8 +77,9 @@ int _read(struct mansession *s, struct message *m) { for (;;) { memset(line, 0, sizeof line); res = get_input(s, line); + debugmsg("res=%d, line: %s",res, line); - if (res > 0 && *line) { + if (res > 0) { debugmsg("Got http: %s", line); /* Do meaningful things here */ if ( !strncmp(line,"POST",4) ) { @@ -93,13 +91,12 @@ int _read(struct mansession *s, struct message *m) { } else if ( !strncasecmp(line, "Content-Length: ", 16) ) { clength = atoi(line+16); } - } else if (res == 0 && *method && clength && *s->inbuf && strlen(s->inbuf)==clength) { + + if (*method && s->inlen==clength) { if ( !strcasecmp(method, "POST") ) { pthread_mutex_lock(&s->lock); strncpy(formdata, s->inbuf, clength); - /* Move remaining data back to the front */ - memmove(s->inbuf, s->inbuf + clength+1, s->inlen - clength); - s->inlen -= clength; + s->inlen = 0; pthread_mutex_unlock(&s->lock); } debugmsg("method: %s", method); @@ -118,6 +115,7 @@ int _read(struct mansession *s, struct message *m) { /* now, let's transform and copy into a standard message block */ res = ParseHTTPInput(formdata, m); return res; + } } else if (res < 0) break; } |