src/server/safs/common.c

changeset 160
389bd0e1ffa9
parent 157
a0c8e752490d
child 161
aadda87bad1b
equal deleted inserted replaced
157:a0c8e752490d 160:389bd0e1ffa9
160 case COMMONSAF_REMOVE_CLIENT: pblock_remove(value, sn->client); break; 160 case COMMONSAF_REMOVE_CLIENT: pblock_remove(value, sn->client); break;
161 case COMMONSAF_REMOVE_VARS: pblock_remove(value, rq->vars); break; 161 case COMMONSAF_REMOVE_VARS: pblock_remove(value, rq->vars); break;
162 case COMMONSAF_REMOVE_HEADERS: pblock_remove(value, rq->headers);break; 162 case COMMONSAF_REMOVE_HEADERS: pblock_remove(value, rq->headers);break;
163 case COMMONSAF_REMOVE_SRVHDRS: pblock_remove(value, rq->srvhdrs); break; 163 case COMMONSAF_REMOVE_SRVHDRS: pblock_remove(value, rq->srvhdrs); break;
164 case COMMONSAF_ABORT: return COMMONSAF_REQ_ABORTED; 164 case COMMONSAF_ABORT: return COMMONSAF_REQ_ABORTED;
165 case COMMONSAF_NOACTION: return COMMONSAF_RET_NOACTION;
165 case COMMONSAF_ERROR: { 166 case COMMONSAF_ERROR: {
167 int len = strlen(value);
168 WSBool isnum = TRUE;
169 int i;
170 for(i=0;i<len;i++) {
171 if(!isdigit(value[i])) {
172 isnum = FALSE;
173 break;
174 }
175 }
176
177 int64_t status;
178 int ret = util_strtoint(value, &status);
179 if(status < 100 || ret > 999 || !ret) {
180 log_ereport(
181 LOG_MISCONFIG,
182 "set-variable: error value must contain a 3-digit http status code");
183 protocol_status(sn, rq, 500, NULL);
184 return COMMONSAF_RET_ERROR;
185 }
186
187 char *msg = isnum ? NULL : sstrtrim(sstr(value + i)).ptr;
188 protocol_status(sn, rq, (int)status, msg);
189
166 return COMMONSAF_REQ_ABORTED; 190 return COMMONSAF_REQ_ABORTED;
167 } 191 }
168 case COMMONSAF_ESCAPE: break; 192 case COMMONSAF_ESCAPE: break;
169 case COMMONSAF_FIND_PATHINFO_FORWARD: break; 193 case COMMONSAF_FIND_PATHINFO_FORWARD: break;
170 case COMMONSAF_HTTP_DOWNGRADE: break; 194 case COMMONSAF_HTTP_DOWNGRADE: break;
171 case COMMONSAF_HTTP_UPGRADE: break; 195 case COMMONSAF_HTTP_UPGRADE: break;
172 case COMMONSAF_KEEP_ALIVE: { 196 case COMMONSAF_KEEP_ALIVE: {
173 rq->rq_attr.keep_alive = util_getboolean(var, 0); 197 rq->rq_attr.keep_alive = util_getboolean(var, 0);
174 break; 198 break;
175 } 199 }
176 case COMMONSAF_NAME: break; 200 case COMMONSAF_NAME: {
201 pblock_kvinsert(pb_key_name, value, strlen(value), rq->vars);
202 break;
203 }
177 case COMMONSAF_SENTHDRS: break; 204 case COMMONSAF_SENTHDRS: break;
178 case COMMONSAF_STOP: return COMMONSAF_RET_STOP; 205 case COMMONSAF_STOP: return COMMONSAF_RET_STOP;
179 case COMMONSAF_URL: break; 206 case COMMONSAF_URL: break;
180 } 207 }
181 return COMMONSAF_RET_DEF; 208 return COMMONSAF_RET_DEF;

mercurial