diff -r 4c89c7683fb6 -r 3c066d52342d src/server/httprequest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/httprequest.h Tue Sep 06 22:27:32 2011 +0200 @@ -0,0 +1,93 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef HTTPREQUEST_H +#define HTTPREQUEST_H + +#include "sstring.h" +#include "sessionhandler.h" +#include "nsapi.h" +#include "pool.h" +#include "session.h" +#include "sstring.h" +#include "request.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _http_request HTTPRequest; +typedef struct _header Header; +typedef struct _header_array HeaderArray; + +struct _http_request { + Connection *connection; + sstr_t request_line; + sstr_t method; + sstr_t uri; + sstr_t httpv; + HeaderArray *headers; + netbuf *netbuf; + NSAPISession *sn; + NSAPIRequest *rq; + pool_handle_t *pool; +}; + +struct _header { + char *name; + char *value; +}; + +struct _header_array { + HeaderArray *next; + Header *headers; + int len; + int alloc; +}; + +HTTPRequest *http_request_new(); + +int handle_request(HTTPRequest *request); + + + +void header_add(HeaderArray *hd, char *name, char *value); + + +/* request.h functions */ +int request_initialize( + pool_handle_t *pool, + HTTPRequest *hrq, + NSAPIRequest *nrq); + +#ifdef __cplusplus +} +#endif + +#endif /* HTTPREQUEST_H */ +