diff options
author | David Troy <dave@popvox.com> | 2006-04-03 16:23:01 +0000 |
---|---|---|
committer | David Troy <dave@popvox.com> | 2006-04-03 16:23:01 +0000 |
commit | bbf337d7f093d32703477f2722591ac08f8230bb (patch) | |
tree | f686336d5fdc65df4008a2fa57f5b861c3f5c780 /src/http.c | |
parent | dc56649b0e188704512719be80ecb6f544cef0e7 (diff) | |
download | astmanproxy-bbf337d7f093d32703477f2722591ac08f8230bb.tar.gz astmanproxy-bbf337d7f093d32703477f2722591ac08f8230bb.tar.xz astmanproxy-bbf337d7f093d32703477f2722591ac08f8230bb.zip |
git-svn-id: http://svncommunity.digium.com/svn/astmanproxy/branches/1.20pre@71 f02b47b9-160a-0410-81a6-dc3441afb0ec
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; } |