src/server/daemon/httprequest.c

changeset 23
a2c8fc23c90e
parent 22
adb0bda54e6b
child 24
1a7853a4257e
equal deleted inserted replaced
22:adb0bda54e6b 23:a2c8fc23c90e
157 absPath.ptr, 157 absPath.ptr,
158 absPath.length, 158 absPath.length,
159 (int*)&absPath.length); 159 (int*)&absPath.length);
160 160
161 /* Decode the abs_path */ 161 /* Decode the abs_path */
162 // TODO: decode abs_path 162 // TODO: decode abs_path (done?)
163 163
164 /* Pass the abs_path as 'uri' in reqpb */ 164 /* Pass the abs_path as 'uri' in reqpb */
165 pblock_kvinsert( 165 pblock_kvinsert(
166 pb_key_uri, 166 pb_key_uri,
167 absPath.ptr, 167 absPath.ptr,
299 rq->phase++; 299 rq->phase++;
300 nsapi_context_next_stage(&rq->context); 300 nsapi_context_next_stage(&rq->context);
301 } 301 }
302 case NSAPIPathCheck: { 302 case NSAPIPathCheck: {
303 //printf(">>> PathCheck\n"); 303 //printf(">>> PathCheck\n");
304 r = nsapi_pathcheck(sn, rq);
305 if(r != REQ_PROCEED) {
306 break;
307 }
304 rq->phase++; 308 rq->phase++;
305 nsapi_context_next_stage(&rq->context); 309 nsapi_context_next_stage(&rq->context);
306 } 310 }
307 case NSAPIObjectType: { 311 case NSAPIObjectType: {
308 //printf(">>> ObjectType\n"); 312 //printf(">>> ObjectType\n");
332 r = nsapi_finish_request(sn, rq); 336 r = nsapi_finish_request(sn, rq);
333 } 337 }
334 } 338 }
335 } while (r == REQ_RESTART); 339 } while (r == REQ_RESTART);
336 340
341 r = nsapi_finish_request(sn, rq);
337 342
338 return r; 343 return r;
339 } 344 }
340 345
341 int nsapi_finish_request(NSAPISession *sn, NSAPIRequest *rq) { 346 int nsapi_finish_request(NSAPISession *sn, NSAPIRequest *rq) {
445 translated.length, 450 translated.length,
446 rq->rq.vars); 451 rq->rq.vars);
447 } 452 }
448 453
449 return REQ_PROCEED; 454 return REQ_PROCEED;
455 }
456
457 int nsapi_pathcheck(NSAPISession *sn, NSAPIRequest *rq) {
458 //printf("nsapi_pathcheck\n");
459 httpd_objset *objset = rq->rq.os;
460
461 if(NCX_OI(rq) == -1) {
462 NCX_OI(rq) = objset->pos - 1;
463 }
464
465 int ret = rq->context.last_req_code;
466 for(int i=NCX_OI(rq);i>=0;i--) {
467 httpd_object *obj = objset->obj[i];
468 dtable *dt = object_get_dtable(obj, NSAPIPathCheck);
469
470 // execute directives
471 for(int j=0;j<dt->ndir;j++) {
472 directive *d = dt->dirs[j];
473
474 /* execute the saf */
475 ret = d->func->func(d->param, (Session*)sn, (Request*)rq);
476 if(ret != REQ_NOACTION) {
477 if(ret == REQ_PROCESSING) {
478 /* save nsapi context */
479 rq->context.objset_index = i;
480
481 /* add +1 to start next round with next function */
482 rq->context.dtable_index = j + 1;
483 } else if(ret == REQ_ABORTED) {
484 if(rq->rq.status_num == PROTOCOL_UNAUTHORIZED) {
485 // TODO: unify error handling
486 protocol_start_response((Session*)sn, (Request*)rq);
487 }
488 }
489
490 return ret;
491 }
492 }
493 }
494
495 return ret;
450 } 496 }
451 497
452 int nsapi_objecttype(NSAPISession *sn, NSAPIRequest *rq) { 498 int nsapi_objecttype(NSAPISession *sn, NSAPIRequest *rq) {
453 //printf("nsapi_objecttype\n"); 499 //printf("nsapi_objecttype\n");
454 httpd_objset *objset = rq->rq.os; 500 httpd_objset *objset = rq->rq.os;

mercurial