src/server/daemon/httprequest.c

changeset 35
4417619a9bbd
parent 26
37ff8bf54b89
child 36
450d2d5f4735
equal deleted inserted replaced
34:2b4574e617c0 35:4417619a9bbd
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <stdlib.h> 30 #include <stdlib.h>
31
31 #include <arpa/inet.h> 32 #include <arpa/inet.h>
32 33
33 #include "../public/nsapi.h" 34 #include "../public/nsapi.h"
34 #include "../util/pool.h" 35 #include "../util/pool.h"
35 #include "../util/pblock.h" 36 #include "../util/pblock.h"
62 // create pool 63 // create pool
63 request->pool = pool_create(); 64 request->pool = pool_create();
64 65
65 // create nsapi data structures 66 // create nsapi data structures
66 NSAPISession *sn = malloc(sizeof(NSAPISession)); 67 NSAPISession *sn = malloc(sizeof(NSAPISession));
68 if(sn == NULL) {
69 /* TODO: error */
70 }
67 NSAPIRequest *rq = malloc(sizeof(NSAPIRequest)); 71 NSAPIRequest *rq = malloc(sizeof(NSAPIRequest));
72 if(rq == NULL) {
73 /* TODO: error */
74 }
68 request->rq = rq; 75 request->rq = rq;
69 rq->phase = NSAPIAuthTrans; 76 rq->phase = NSAPIAuthTrans;
70 77
71 // fill session structure 78 // fill session structure
72 sn->sys_fd = request->connection->fd; 79 sn->sys_fd = request->connection->fd;
334 case REQ_FINISH: { 341 case REQ_FINISH: {
335 //printf(">>> Finish\n"); 342 //printf(">>> Finish\n");
336 r = nsapi_finish_request(sn, rq); 343 r = nsapi_finish_request(sn, rq);
337 } 344 }
338 } 345 }
346
347 if(r == REQ_ABORTED) {
348 nsapi_error_request(sn, rq);
349 }
350
339 } while (r == REQ_RESTART); 351 } while (r == REQ_RESTART);
340 352
341 r = nsapi_finish_request(sn, rq); 353 r = nsapi_finish_request(sn, rq);
342 354
343 return r; 355 return r;
346 int nsapi_finish_request(NSAPISession *sn, NSAPIRequest *rq) { 358 int nsapi_finish_request(NSAPISession *sn, NSAPIRequest *rq) {
347 // TODO: free memory 359 // TODO: free memory
348 close(sn->sys_fd); 360 close(sn->sys_fd);
349 361
350 return 0; 362 return 0;
363 }
364
365 int nsapi_error_request(NSAPISession *sn, NSAPIRequest *rq) {
366 // TODO
367
368 return REQ_PROCEED;
351 } 369 }
352 370
353 int nsapi_authtrans(NSAPISession *sn, NSAPIRequest *rq) { 371 int nsapi_authtrans(NSAPISession *sn, NSAPIRequest *rq) {
354 HTTPObjectConfig *objconf = rq->vs->objects; 372 HTTPObjectConfig *objconf = rq->vs->objects;
355 httpd_object *obj = objconf->objects[0]; 373 httpd_object *obj = objconf->objects[0];

mercurial