Index: gwlib/http.c
===================================================================
--- gwlib/http.c	(revision 5276)
+++ gwlib/http.c	(working copy)
@@ -658,7 +658,7 @@
  * Order is sequenced by the enum in the header
  */
 static char *http_methods[] = {
-    "GET", "POST", "HEAD"
+    "GET", "POST", "HEAD", "PUT"
 };
 
 /*
@@ -1603,7 +1603,7 @@
     char buf[128];    
     Octstr *request = NULL;
 
-    if (trans->method == HTTP_METHOD_POST) {
+    if (trans->method == HTTP_METHOD_POST || trans->method == HTTP_METHOD_PUT) {
         /* 
          * Add a Content-Length header.  Override an existing one, if
          * necessary.  We must have an accurate one in order to use the
@@ -2222,6 +2222,8 @@
         *method = HTTP_METHOD_POST;
     else if (octstr_compare(method_str, octstr_imm("HEAD")) == 0)
         *method = HTTP_METHOD_HEAD;
+    else if (octstr_compare(method_str, octstr_imm("PUT")) == 0)
+        *method = HTTP_METHOD_PUT;
     else
         goto error;
 
@@ -2530,11 +2532,11 @@
 
 
 /*
- * Parse CGI variables from the path given in a GET. Return a list
- * of HTTPCGIvar pointers. Modify the url so that the variables are
- * removed.
+ * Parse CGI variables from the url in case of GET/HEAD or from the body in case of POST/PUT.
+ * Return a list of HTTPCGIvar pointers.
+ * Modify the url so that the variables are removed.
  */
-static List *parse_cgivars(Octstr *url)
+static List *parse_cgivars(int method, Octstr *url, Octstr *body)
 {
     HTTPCGIVar *v;
     List *list;
@@ -2541,6 +2543,9 @@
     int query, et, equals;
     Octstr *arg, *args;
 
+    if (method == HTTP_METHOD_POST || method == HTTP_METHOD_PUT) {
+        args = octstr_duplicate(body);
+    } else {
     query = octstr_search_char(url, '?', 0);
     if (query == -1)
         return gwlist_create();
@@ -2547,6 +2552,7 @@
 
     args = octstr_copy(url, query + 1, octstr_len(url));
     octstr_truncate(url, query);
+    }
 
     list = gwlist_create();
 
@@ -2597,13 +2603,15 @@
         }
     } while(client == NULL);
     
+    debug("gwlib.http", 0, "HTTP: Got %s request with url='%s' and body='%s'",
+          http_method2name(client->method), octstr_get_cstr(client->url), octstr_get_cstr(client->request->body));
     *client_ip = octstr_duplicate(client->ip);
     *url = client->url;
     *headers = client->request->headers;
     *body = client->request->body;
-    *cgivars = parse_cgivars(client->url);
+    *cgivars = parse_cgivars(client->method, client->url, client->request->body);
     
-    if (client->method != HTTP_METHOD_POST) {
+    if (client->method != HTTP_METHOD_POST && client->method != HTTP_METHOD_PUT) {
         octstr_destroy(*body);
         *body = NULL;
     }
@@ -3646,6 +3654,9 @@
     else if (octstr_str_compare(method, "HEAD") == 0) {
         return HTTP_METHOD_HEAD;
     } 
+    else if (octstr_str_compare(method, "PUT") == 0) {
+        return HTTP_METHOD_PUT;
+    }
 
     return -1;
 }
@@ -3653,7 +3664,7 @@
 
 char *http_method2name(int method)
 {
-    gw_assert(method > 0 && method <= 3);
+    gw_assert(method >= HTTP_METHOD_GET && method <= HTTP_METHOD_PUT);
 
     return http_methods[method-1];
 }
Index: gwlib/http.h
===================================================================
--- gwlib/http.h	(revision 5276)
+++ gwlib/http.h	(working copy)
@@ -200,9 +200,10 @@
  * probably should be.
  */
 enum {
-	HTTP_METHOD_GET = 1,
+	HTTP_METHOD_GET  = 1,
 	HTTP_METHOD_POST = 2,
-	HTTP_METHOD_HEAD = 3
+	HTTP_METHOD_HEAD = 3,
+	HTTP_METHOD_PUT  = 4
 };
 
 /*
