adds set-variable error

Thu, 26 Jan 2017 17:23:11 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 26 Jan 2017 17:23:11 +0100
changeset 160
389bd0e1ffa9
parent 157
a0c8e752490d
child 161
aadda87bad1b

adds set-variable error

src/server/safs/common.c file | annotate | diff | comparison | revisions
--- a/src/server/safs/common.c	Tue Jan 24 23:19:48 2017 +0100
+++ b/src/server/safs/common.c	Thu Jan 26 17:23:11 2017 +0100
@@ -162,7 +162,31 @@
         case COMMONSAF_REMOVE_HEADERS: pblock_remove(value, rq->headers);break;
         case COMMONSAF_REMOVE_SRVHDRS: pblock_remove(value, rq->srvhdrs); break;
         case COMMONSAF_ABORT: return COMMONSAF_REQ_ABORTED;
+        case COMMONSAF_NOACTION: return COMMONSAF_RET_NOACTION;
         case COMMONSAF_ERROR: {
+            int len = strlen(value);
+            WSBool isnum = TRUE;
+            int i;
+            for(i=0;i<len;i++) {
+                if(!isdigit(value[i])) {
+                    isnum = FALSE;
+                    break;
+                }
+            }
+            
+            int64_t status;
+            int ret = util_strtoint(value, &status);
+            if(status < 100 || ret > 999 || !ret) {
+                log_ereport(
+                        LOG_MISCONFIG,
+                        "set-variable: error value must contain a 3-digit http status code");
+                protocol_status(sn, rq, 500, NULL);
+                return COMMONSAF_RET_ERROR;
+            }
+            
+            char *msg = isnum ? NULL : sstrtrim(sstr(value + i)).ptr;
+            protocol_status(sn, rq, (int)status, msg);
+            
             return COMMONSAF_REQ_ABORTED;
         }
         case COMMONSAF_ESCAPE: break;
@@ -173,7 +197,10 @@
             rq->rq_attr.keep_alive = util_getboolean(var, 0);
             break;
         }
-        case COMMONSAF_NAME: break;
+        case COMMONSAF_NAME: {
+            pblock_kvinsert(pb_key_name, value, strlen(value), rq->vars);
+            break;
+        }
         case COMMONSAF_SENTHDRS: break;
         case COMMONSAF_STOP: return COMMONSAF_RET_STOP;
         case COMMONSAF_URL: break;

mercurial