diff -r adb0bda54e6b -r a2c8fc23c90e src/server/daemon/httprequest.c --- a/src/server/daemon/httprequest.c Thu Feb 16 15:08:38 2012 +0100 +++ b/src/server/daemon/httprequest.c Wed Feb 22 23:20:39 2012 +0100 @@ -159,7 +159,7 @@ (int*)&absPath.length); /* Decode the abs_path */ - // TODO: decode abs_path + // TODO: decode abs_path (done?) /* Pass the abs_path as 'uri' in reqpb */ pblock_kvinsert( @@ -301,6 +301,10 @@ } case NSAPIPathCheck: { //printf(">>> PathCheck\n"); + r = nsapi_pathcheck(sn, rq); + if(r != REQ_PROCEED) { + break; + } rq->phase++; nsapi_context_next_stage(&rq->context); } @@ -334,6 +338,7 @@ } } while (r == REQ_RESTART); + r = nsapi_finish_request(sn, rq); return r; } @@ -449,6 +454,47 @@ return REQ_PROCEED; } +int nsapi_pathcheck(NSAPISession *sn, NSAPIRequest *rq) { + //printf("nsapi_pathcheck\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, NSAPIPathCheck); + + // execute directives + for(int j=0;jndir;j++) { + directive *d = dt->dirs[j]; + + /* execute the saf */ + ret = d->func->func(d->param, (Session*)sn, (Request*)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; + } else if(ret == REQ_ABORTED) { + if(rq->rq.status_num == PROTOCOL_UNAUTHORIZED) { + // TODO: unify error handling + protocol_start_response((Session*)sn, (Request*)rq); + } + } + + return ret; + } + } + } + + return ret; +} + int nsapi_objecttype(NSAPISession *sn, NSAPIRequest *rq) { //printf("nsapi_objecttype\n"); httpd_objset *objset = rq->rq.os;