summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Troy <dave@popvox.com>2006-04-03 20:56:45 +0000
committerDavid Troy <dave@popvox.com>2006-04-03 20:56:45 +0000
commit6a521bdca3afa676e110ba2bada7698f41504084 (patch)
tree0d71ee894b077e8433cc7a252ae5235acf598612
parent45f93b7efc02bc2d6d2c3a5150ee7065ee7ae482 (diff)
downloadastmanproxy-6a521bdca3afa676e110ba2bada7698f41504084.tar.gz
astmanproxy-6a521bdca3afa676e110ba2bada7698f41504084.tar.xz
astmanproxy-6a521bdca3afa676e110ba2bada7698f41504084.zip
git-svn-id: http://svncommunity.digium.com/svn/astmanproxy/branches/1.20pre@76 f02b47b9-160a-0410-81a6-dc3441afb0ec
-rw-r--r--src/http.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/src/http.c b/src/http.c
index fcc6bcc..ff876a1 100644
--- a/src/http.c
+++ b/src/http.c
@@ -80,45 +80,47 @@ int _read(struct mansession *s, struct message *m) {
if (res > 0) {
debugmsg("Got http: %s", line);
- /* Do meaningful things here */
- if ( !strncmp(line,"POST",4) ) {
- strncpy(method, line, 4);
- } else if ( !strncmp(line,"GET",3) ) {
- /* GET /?Action=Ping&ActionID=Foo HTTP/1.1 */
- strncpy(method, line, 3);
- memcpy(formdata, line+6, strstr(line, " HTTP")-line-6);
- } else if ( !strncasecmp(line, "Content-Length: ", 16) ) {
- clength = atoi(line+16);
- }
-
- if (*method && s->inlen==clength) {
- if ( !strcasecmp(method, "POST") ) {
+
+ if ( !clength && !strncasecmp(line, "Content-Length: ", 16) )
+ clength = atoi(line+16);
+
+ if (!*method) {
+ if ( !strncmp(line,"POST",4) ) {
+ strncpy(method, line, 4);
+ } else if ( !strncmp(line,"GET",3) && strlen(line)>14 ) {
+ /* GET / HTTP/1.1 ---- this is bad */
+ /* GET /?Action=Ping&ActionID=Foo HTTP/1.1 */
+ strncpy(method, line, 3);
+ memcpy(formdata, line+6, strstr(line, " HTTP")-line-6);
+ }
+ }
+ } else if (res == 0) {
+ if (*method && !*formdata) {
+ if ( !strcasecmp(method, "POST") && clength && s->inlen==clength) {
pthread_mutex_lock(&s->lock);
strncpy(formdata, s->inbuf, clength);
s->inlen = 0;
pthread_mutex_unlock(&s->lock);
}
- debugmsg("method: %s", method);
- debugmsg("clength: %d", clength);
- debugmsg("formdata: %s", formdata);
- debugmsg("s->inbuf: %s", s->inbuf);
- debugmsg("s->inlen: %d", s->inlen);
-
- BuildHTTPHeader(header);
- pthread_mutex_lock(&s->lock);
- s->inputcomplete = 1;
- ast_carefulwrite(s->fd, header, strlen(header), s->writetimeout);
- pthread_mutex_unlock(&s->lock);
- debugmsg("header: %s", header);
-
- /* now, let's transform and copy into a standard message block */
- res = ParseHTTPInput(formdata, m);
- return res;
}
- } else if (res < 0)
+ }
+
+ if (res < 0)
break;
- }
+ if (*method && *formdata) {
+ BuildHTTPHeader(header);
+ pthread_mutex_lock(&s->lock);
+ s->inputcomplete = 1;
+ ast_carefulwrite(s->fd, header, strlen(header), s->writetimeout);
+ pthread_mutex_unlock(&s->lock);
+ debugmsg("header: %s", header);
+
+ /* now, let's transform and copy into a standard message block */
+ res = ParseHTTPInput(formdata, m);
+ return res;
+ }
+ }
return -1;
}