src/server/httprequest.c

changeset 12
34aa8001ea53
parent 10
e3ae779232a9
equal deleted inserted replaced
11:24d804a2799f 12:34aa8001ea53
323 char *name = NULL; 323 char *name = NULL;
324 char *ppath = NULL; 324 char *ppath = NULL;
325 for(int i=NCX_DI(rq);i<dt->ndir;i++) { 325 for(int i=NCX_DI(rq);i<dt->ndir;i++) {
326 directive *d = dt->dirs[i]; 326 directive *d = dt->dirs[i];
327 327
328 printf("execute [%s]\n", d->func->name);
329 ret = d->func->func(d->param, (Session*)sn, (Request*)rq); 328 ret = d->func->func(d->param, (Session*)sn, (Request*)rq);
330 329
331 /* check for name or ppath */ 330 /* check for name or ppath */
332 name = pblock_findkeyval(pb_key_name, rq->rq.vars); 331 name = pblock_findkeyval(pb_key_name, rq->rq.vars);
333 ppath = pblock_findkeyval(pb_key_ppath, rq->rq.vars); 332 ppath = pblock_findkeyval(pb_key_ppath, rq->rq.vars);
456 if(NCX_OI(rq) == -1) { 455 if(NCX_OI(rq) == -1) {
457 NCX_OI(rq) = objset->pos - 1; 456 NCX_OI(rq) = objset->pos - 1;
458 } 457 }
459 458
460 int ret = rq->context.last_req_code; 459 int ret = rq->context.last_req_code;
460 char *content_type = NULL;
461 for(int i=NCX_OI(rq);i>=0;i--) { 461 for(int i=NCX_OI(rq);i>=0;i--) {
462 httpd_object *obj = objset->obj[i]; 462 httpd_object *obj = objset->obj[i];
463 dtable *dt = object_get_dtable(obj, NSAPIService); 463 dtable *dt = object_get_dtable(obj, NSAPIService);
464 464
465 // execute directives 465 // execute directives
466 for(int j=0;j<dt->ndir;j++) { 466 for(int j=0;j<dt->ndir;j++) {
467 directive *d = dt->dirs[j]; 467 directive *d = dt->dirs[j];
468
469 /* check type parameter */
470 char *dtp = pblock_findkeyval(pb_key_type, d->param);
471 if(dtp) {
472 /* type parameter for directive */
473 if(!content_type) {
474 content_type = pblock_findkeyval(
475 pb_key_content_type,
476 rq->rq.srvhdrs);
477 }
478 /* compare types */
479 if(strcmp(dtp, content_type) != 0) {
480 continue;
481 }
482 }
468 483
469 ret = d->func->func(d->param, (Session*)sn, (Request*)rq); 484 ret = d->func->func(d->param, (Session*)sn, (Request*)rq);
470 if(ret != REQ_NOACTION) { 485 if(ret != REQ_NOACTION) {
471 if(ret == REQ_PROCESSING) { 486 if(ret == REQ_PROCESSING) {
472 /* save nsapi context */ 487 /* save nsapi context */

mercurial