1 /* |
1 /* |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 * |
3 * |
4 * Copyright 2011 Olaf Wintermann. All rights reserved. |
4 * Copyright 2013 Olaf Wintermann. All rights reserved. |
5 * |
5 * |
6 * Redistribution and use in source and binary forms, with or without |
6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are met: |
7 * modification, are permitted provided that the following conditions are met: |
8 * |
8 * |
9 * 1. Redistributions of source code must retain the above copyright |
9 * 1. Redistributions of source code must retain the above copyright |
38 #include "../util/util.h" |
38 #include "../util/util.h" |
39 #include "httprequest.h" |
39 #include "httprequest.h" |
40 #include "config.h" |
40 #include "config.h" |
41 #include "vserver.h" |
41 #include "vserver.h" |
42 #include "httplistener.h" |
42 #include "httplistener.h" |
|
43 #include "error.h" |
43 |
44 |
44 HTTPRequest *http_request_new() { |
45 HTTPRequest *http_request_new() { |
45 HTTPRequest *req = malloc(sizeof(HTTPRequest)); |
46 HTTPRequest *req = malloc(sizeof(HTTPRequest)); |
46 req->connection = NULL; |
47 req->connection = NULL; |
47 req->uri.ptr = NULL; |
48 req->uri.ptr = NULL; |
355 r = nsapi_finish_request(sn, rq); |
356 r = nsapi_finish_request(sn, rq); |
356 } |
357 } |
357 } |
358 } |
358 |
359 |
359 if(r == REQ_ABORTED) { |
360 if(r == REQ_ABORTED) { |
360 nsapi_error_request(sn, rq); |
361 // if an error occurred, we send an error page |
|
362 nsapi_error_request((Session*)sn, (Request*)rq); |
|
363 break; |
361 } |
364 } |
362 |
365 |
363 } while (r == REQ_RESTART); |
366 } while (r == REQ_RESTART); |
364 |
367 |
365 if(r != REQ_PROCESSING) { |
368 if(r != REQ_PROCESSING) { |
372 int nsapi_finish_request(NSAPISession *sn, NSAPIRequest *rq) { |
375 int nsapi_finish_request(NSAPISession *sn, NSAPIRequest *rq) { |
373 // TODO: free memory |
376 // TODO: free memory |
374 close(sn->sys_fd); |
377 close(sn->sys_fd); |
375 |
378 |
376 return 0; |
379 return 0; |
377 } |
|
378 |
|
379 int nsapi_error_request(NSAPISession *sn, NSAPIRequest *rq) { |
|
380 // TODO |
|
381 |
|
382 return REQ_PROCEED; |
|
383 } |
380 } |
384 |
381 |
385 int nsapi_authtrans(NSAPISession *sn, NSAPIRequest *rq) { |
382 int nsapi_authtrans(NSAPISession *sn, NSAPIRequest *rq) { |
386 HTTPObjectConfig *objconf = rq->vs->objects; |
383 HTTPObjectConfig *objconf = rq->vs->objects; |
387 httpd_object *obj = objconf->objects[0]; |
384 httpd_object *obj = objconf->objects[0]; |