src/server/daemon/error.c

changeset 137
ca0cf1016a8b
parent 132
e9afb5387007
child 195
d367b687bc74
--- a/src/server/daemon/error.c	Tue Dec 27 19:36:19 2016 +0100
+++ b/src/server/daemon/error.c	Tue Dec 27 19:50:20 2016 +0100
@@ -45,19 +45,25 @@
 
 int nsapi_error_request(Session *sn, Request *rq) {
     short status = rq->status_num;
-    sstr_t msg = error_std;
-    switch(status) {
-        case 403: {
-            msg = error_403;
-            break;
-        }
-        case 404: {
-            msg = error_404;
-            break;
-        }
-        case 500: {
-            msg = error_500;
-            break;
+    sstr_t msg;
+    if(status < 400) {
+        msg.ptr = NULL;
+        msg.length = 0;
+    } else {
+        switch(status) {
+            default: msg = error_std;
+            case 403: {
+                msg = error_403;
+                break;
+            }
+            case 404: {
+                msg = error_404;
+                break;
+            }
+            case 500: {
+                msg = error_500;
+                break;
+            }
         }
     }
     
@@ -68,7 +74,9 @@
     pblock_nvinsert("content-type", "text/html", rq->srvhdrs);
     http_start_response(sn, rq);
     
-    net_write(sn->csd, msg.ptr, msg.length);
+    if(msg.length > 0) {
+        net_write(sn->csd, msg.ptr, msg.length);
+    }
     
     return REQ_PROCEED;
 }

mercurial