--- a/src/server/daemon/httprequest.c Tue Jan 01 19:22:56 2013 +0100 +++ b/src/server/daemon/httprequest.c Wed Jan 02 16:03:50 2013 +0100 @@ -110,6 +110,12 @@ /* Pass request line as "clf-request" */ /* TODO: with or without \r\n ? */ + // hack to remove \r\n + sstr_t clfreq = request->request_line; + while(clfreq.ptr[clfreq.length - 1] < 33) { + clfreq.length--; + } + request->request_line = clfreq; pblock_kvinsert( pb_key_clf_request, request->request_line.ptr, @@ -348,6 +354,10 @@ } case NSAPIAddLog: { //printf(">>> AddLog\n"); + r = nsapi_addlog(sn, rq); + if(r != REQ_PROCESSING && r != REQ_ABORTED) { + break; + } rq->phase++; nsapi_context_next_stage(&rq->context); } @@ -669,6 +679,43 @@ return ret; } +int nsapi_addlog(NSAPISession *sn, NSAPIRequest *rq) { + //printf("nsapi_addlog\n"); + httpd_objset *objset = rq->rq.os; + + if(NCX_OI(rq) == -1) { + NCX_OI(rq) = objset->pos - 1; + } + + int ret = rq->context.last_req_code; + for(int i=NCX_OI(rq);i>=0;i--) { + httpd_object *obj = objset->obj[i]; + dtable *dt = object_get_dtable(obj, NSAPIAddLog); + + // execute directives + for(int j=NCX_DI(rq);j<dt->ndir;j++) { + if(ret == REQ_NOACTION) { + directive *d = dt->dirs[j]; + ret = nsapi_exec(d, sn, rq); + } + + if(ret != REQ_NOACTION) { + if(ret == REQ_PROCESSING) { + /* save nsapi context */ + rq->context.objset_index = i; + + /* add +1 to start next round with next function */ + rq->context.dtable_index = j + 1; + } + + return ret; + } + } + } + + return REQ_PROCEED; +} + struct _tpd_data { NSAPISession *sn; NSAPIRequest *rq;