Diagnotic tuning
[pazpar2-moved-to-github.git] / src / http.c
index 401f5ae..5430f6e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: http.c,v 1.1 2006-12-20 20:47:16 quinn Exp $
+ * $Id: http.c,v 1.4 2006-12-21 04:27:17 quinn Exp $
  */
 
 #include <stdio.h>
@@ -263,6 +263,7 @@ struct http_request *http_parse_request(struct http_channel *c, struct http_buf
     if (http_buf_read(queue, buf, len) < len)
         return 0;
 
+    r->search = "";
     r->channel = c;
     r->arguments = 0;
     r->headers = 0;
@@ -293,6 +294,7 @@ struct http_request *http_parse_request(struct http_channel *c, struct http_buf
     r->path = nmem_strdup(c->nmem, buf);
     if (p2)
     {
+        r->search = nmem_strdup(c->nmem, p2);
         // Parse Arguments
         while (*p2)
         {
@@ -517,7 +519,12 @@ static void http_io(IOCHAN i, int event)
         case EVENT_INPUT:
             htbuf = http_buf_create();
             res = read(iochan_getfd(i), htbuf->buf, HTTP_BUF_SIZE -1);
-            if (res <= 0 && errno != EAGAIN)
+            if (res == -1 && errno == EAGAIN)
+            {
+                http_buf_destroy(htbuf);
+                return;
+            }
+            if (res <= 0)
             {
                 http_buf_destroy(htbuf);
                 http_destroy(i);
@@ -532,7 +539,6 @@ static void http_io(IOCHAN i, int event)
 
             if (hc->state == Http_Busy)
                 return;
-
             if ((reqlen = request_check(hc->iqueue)) <= 2)
                 return;
 
@@ -544,8 +550,10 @@ static void http_io(IOCHAN i, int event)
                 return;
             }
             hc->response = 0;
-            yaz_log(YLOG_LOG, "Request: %s %s v %s", hc->request->method,
-                    hc->request->path, hc->request->http_version);
+            yaz_log(YLOG_LOG, "Request: %s %s%s%s", hc->request->method,
+                    hc->request->path,
+                    *hc->request->search ? "?" : "",
+                    hc->request->search);
             if (http_weshouldproxy(hc->request))
                 http_proxy(hc->request);
             else
@@ -750,7 +758,7 @@ static void http_accept(IOCHAN i, int event)
     if (fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0)
         yaz_log(YLOG_FATAL|YLOG_ERRNO, "fcntl2");
 
-    yaz_log(YLOG_LOG, "New command connection");
+    yaz_log(YLOG_DEBUG, "New command connection");
     c = iochan_create(s, http_io, EVENT_INPUT | EVENT_EXCEPT);
 
     ch = http_create();