/[monit]/monit/http/processor.c
ViewVC logotype

Diff of /monit/http/processor.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.33 by hauk, Fri Nov 21 16:47:12 2003 UTC revision 1.34 by hauk, Fri Nov 21 19:10:59 2003 UTC
# Line 743  static void create_headers(HttpRequest r Line 743  static void create_headers(HttpRequest r
743   */   */
744  static int create_parameters(HttpRequest req) {  static int create_parameters(HttpRequest req) {
745    
746    int alloc= FALSE;    char query_string[REQ_STRLEN]= {0};
   char *query_string= NULL;  
747    
748    if(IS(req->method, METHOD_POST) && get_header(req, "Content-Length")) {    if(IS(req->method, METHOD_POST) && get_header(req, "Content-Length")) {
749      int n;      int n;
# Line 753  static int create_parameters(HttpRequest Line 752  static int create_parameters(HttpRequest
752      if(1 != sscanf(get_header(req, "Content-Length"), "%d", &len)) {      if(1 != sscanf(get_header(req, "Content-Length"), "%d", &len)) {
753        return FALSE;        return FALSE;
754      }      }
755      if(len < 0)      if(len < 0 || len > REQ_STRLEN)
756        return FALSE;        return FALSE;
757      if(len==0)      if(len==0)
758        return TRUE;        return TRUE;
   
     query_string=  xcalloc(sizeof(char), len + 1);  
         
759      if(((n= socket_read(S, query_string, len)) <= 0) || (n != len)) {      if(((n= socket_read(S, query_string, len)) <= 0) || (n != len)) {
       FREE(query_string);  
760        return FALSE;        return FALSE;
761      }      }
762      query_string[n]= 0;      query_string[n]= 0;
     alloc= TRUE;  
763    } else if(IS(req->method, METHOD_GET)) {    } else if(IS(req->method, METHOD_GET)) {
764      char *p;      char *p;
765      if(NULL != (p= strchr(req->url, '?'))) {      if(NULL != (p= strchr(req->url, '?'))) {
766        *p++= 0;        *p++= 0;
767        query_string= p;        strncpy(query_string, p, REQ_STRLEN);
768      }      }
769    }    }
770        if(*query_string) {
   if(query_string && *query_string) {  
771      char *p;      char *p;
772      if(NULL != (p= strchr(query_string, '/'))) {      if(NULL != (p= strchr(query_string, '/'))) {
773        *p++= 0;        *p++= 0;
774        req->pathinfo= p;        req->pathinfo= xstrdup(p);
775      }      }
776      req->params= parse_parameters(query_string);      req->params= parse_parameters(query_string);
777    }    }
   
   if(alloc)FREE(query_string);  
778        
779    return TRUE;    return TRUE;
780        
# Line 825  static void destroy_HttpRequest(HttpRequ Line 816  static void destroy_HttpRequest(HttpRequ
816    if(req) {    if(req) {
817            
818      FREE(req->method);      FREE(req->method);
819      FREE(req->url); /* req->pathinfo is freed with url */      FREE(req->url);
820        FREE(req->pathinfo);
821      FREE(req->protocol);      FREE(req->protocol);
822      FREE(req->remote_user);      FREE(req->remote_user);
823      if(req->headers)destroy_entry(req->headers);      if(req->headers)destroy_entry(req->headers);

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26