src/server/daemon/httprequest.c

changeset 21
627b09ee74e4
parent 20
7b235fa88008
child 22
adb0bda54e6b
equal deleted inserted replaced
20:7b235fa88008 21:627b09ee74e4
160 160
161 /* Decode the abs_path */ 161 /* Decode the abs_path */
162 // TODO: decode abs_path 162 // TODO: decode abs_path
163 163
164 /* Pass the abs_path as 'uri' in reqpb */ 164 /* Pass the abs_path as 'uri' in reqpb */
165 // TODO: pass abs_path to reqpb
166 // TODO: replace this code
167 pblock_kvinsert( 165 pblock_kvinsert(
168 pb_key_uri, 166 pb_key_uri,
169 absPath.ptr, 167 absPath.ptr,
170 absPath.length, 168 absPath.length,
171 rq->rq.reqpb); 169 rq->rq.reqpb);
287 case NSAPIAuthTrans: { 285 case NSAPIAuthTrans: {
288 rq->phase++; 286 rq->phase++;
289 nsapi_context_next_stage(&rq->context); 287 nsapi_context_next_stage(&rq->context);
290 } 288 }
291 case NSAPINameTrans: { 289 case NSAPINameTrans: {
292 printf(">>> NameTrans\n"); 290 //printf(">>> NameTrans\n");
293 r = nsapi_nametrans(sn, rq); 291 r = nsapi_nametrans(sn, rq);
294 if(r != REQ_PROCEED) { 292 if(r != REQ_PROCEED) {
295 break; 293 break;
296 } 294 }
297 rq->phase++; 295 rq->phase++;
298 nsapi_context_next_stage(&rq->context); 296 nsapi_context_next_stage(&rq->context);
299 } 297 }
300 case NSAPIPathCheck: { 298 case NSAPIPathCheck: {
301 printf(">>> PathCheck\n"); 299 //printf(">>> PathCheck\n");
302 rq->phase++; 300 rq->phase++;
303 nsapi_context_next_stage(&rq->context); 301 nsapi_context_next_stage(&rq->context);
304 } 302 }
305 case NSAPIObjectType: { 303 case NSAPIObjectType: {
306 printf(">>> ObjectType\n"); 304 //printf(">>> ObjectType\n");
307 r = nsapi_objecttype(sn, rq); 305 r = nsapi_objecttype(sn, rq);
308 if(r != REQ_PROCEED) { 306 if(r != REQ_PROCEED) {
309 break; 307 break;
310 } 308 }
311 rq->phase++; 309 rq->phase++;
312 nsapi_context_next_stage(&rq->context); 310 nsapi_context_next_stage(&rq->context);
313 } 311 }
314 case NSAPIService: { 312 case NSAPIService: {
315 printf(">>> Service\n"); 313 //printf(">>> Service\n");
316 r = nsapi_service(sn, rq); 314 r = nsapi_service(sn, rq);
317 if(r != REQ_PROCEED) { 315 if(r != REQ_PROCEED) {
318 break; 316 break;
319 } 317 }
320 rq->phase++; 318 rq->phase++;
321 nsapi_context_next_stage(&rq->context); 319 nsapi_context_next_stage(&rq->context);
322 } 320 }
323 case NSAPIAddLog: { 321 case NSAPIAddLog: {
324 printf(">>> AddLog\n"); 322 //printf(">>> AddLog\n");
325 rq->phase++; 323 rq->phase++;
326 nsapi_context_next_stage(&rq->context); 324 nsapi_context_next_stage(&rq->context);
327 } 325 }
328 case REQ_FINISH: { 326 case REQ_FINISH: {
329 printf(">>> Finish\n"); 327 //printf(">>> Finish\n");
330 r = nsapi_finish_request(sn, rq); 328 r = nsapi_finish_request(sn, rq);
331 } 329 }
332 } 330 }
333 } while (r == REQ_RESTART); 331 } while (r == REQ_RESTART);
334 332
343 return 0; 341 return 0;
344 } 342 }
345 343
346 int nsapi_nametrans(NSAPISession *sn, NSAPIRequest *rq) { 344 int nsapi_nametrans(NSAPISession *sn, NSAPIRequest *rq) {
347 HTTPObjectConfig *objconf = rq->vs->objects; 345 HTTPObjectConfig *objconf = rq->vs->objects;
348 printf("nsapi_nametrans\n"); 346 //printf("nsapi_nametrans\n");
349 httpd_objset *objset = objset_create(sn->sn.pool); 347 httpd_objset *objset = objset_create(sn->sn.pool);
350 rq->rq.os = objset; 348 rq->rq.os = objset;
351 /* first object in objconf is the default object TODO: make sure it is */ 349 /* first object in objconf is the default object TODO: make sure it is */
352 objset_add_object(sn->sn.pool, objset, objconf->objects[0]); 350 objset_add_object(sn->sn.pool, objset, objconf->objects[0]);
353 351
417 415
418 return REQ_PROCEED; 416 return REQ_PROCEED;
419 } 417 }
420 418
421 int nsapi_objecttype(NSAPISession *sn, NSAPIRequest *rq) { 419 int nsapi_objecttype(NSAPISession *sn, NSAPIRequest *rq) {
422 printf("nsapi_objecttype\n"); 420 //printf("nsapi_objecttype\n");
423 httpd_objset *objset = rq->rq.os; 421 httpd_objset *objset = rq->rq.os;
424 422
425 if(NCX_OI(rq) == -1) { 423 if(NCX_OI(rq) == -1) {
426 /* object index is undefined -> define correct object index */ 424 /* object index is undefined -> define correct object index */
427 NCX_OI(rq) = objset->pos - 1; 425 NCX_OI(rq) = objset->pos - 1;
484 482
485 return REQ_PROCEED; 483 return REQ_PROCEED;
486 } 484 }
487 485
488 int nsapi_service(NSAPISession *sn, NSAPIRequest *rq) { 486 int nsapi_service(NSAPISession *sn, NSAPIRequest *rq) {
489 printf("nsapi_service\n"); 487 //printf("nsapi_service\n");
490 httpd_objset *objset = rq->rq.os; 488 httpd_objset *objset = rq->rq.os;
491 489
492 if(NCX_OI(rq) == -1) { 490 if(NCX_OI(rq) == -1) {
493 NCX_OI(rq) = objset->pos - 1; 491 NCX_OI(rq) = objset->pos - 1;
494 } 492 }
529 if(!method_match(dmt, method)) { 527 if(!method_match(dmt, method)) {
530 continue; 528 continue;
531 } 529 }
532 } 530 }
533 531
532 /* execute the saf */
534 ret = d->func->func(d->param, (Session*)sn, (Request*)rq); 533 ret = d->func->func(d->param, (Session*)sn, (Request*)rq);
535 if(ret != REQ_PROCEED) { 534 if(ret != REQ_PROCEED) {
536 fprintf(stderr, "saf not proceed\n"); 535 fprintf(stderr, "saf not proceed\n");
537 } 536 }
538 if(ret != REQ_NOACTION) { 537 if(ret != REQ_NOACTION) {

mercurial