Mercurial > hg > index.fcgi > gift-gnutella > gift-gnutella-0.0.11-1pba
view src/http_request.h @ 0:d39e1d0d75b6
initial add
author | paulo@hit-nxdomain.opendns.com |
---|---|
date | Sat, 20 Feb 2010 21:18:28 -0800 |
parents | |
children |
line source
1 /*
2 * $Id: http_request.h,v 1.11 2004/03/24 06:20:48 hipnod Exp $
3 *
4 * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net)
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 */
17 #ifndef GIFT_GT_HTTP_REQUEST_H_
18 #define GIFT_GT_HTTP_REQUEST_H_
20 /*****************************************************************************/
22 struct gt_http_request;
24 /*****************************************************************************/
26 typedef void (*HttpCloseFunc) (struct gt_http_request *req, int error_code);
28 typedef BOOL (*HttpReceiveFunc) (struct gt_http_request *req, char *data,
29 size_t len);
30 typedef BOOL (*HttpAddHeaderFunc) (struct gt_http_request *req,
31 Dataset **headers);
32 typedef BOOL (*HttpRedirectFunc) (struct gt_http_request *req,
33 const char *host, const char *path);
35 /*****************************************************************************/
37 typedef struct gt_http_request
38 {
39 char *host;
40 char *path;
41 char *request;
42 char *proxy;
44 TCPC *c;
45 Dataset *headers;
46 timer_id timeout;
48 /* amount of data to expect:
49 * (1) in the chunk, when Transfer-Encoding: Chunked is used
50 * (2) in the body, from the Content-Length: header */
51 unsigned long size;
52 size_t max_len;
53 size_t recvd_len;
55 /* number of redirects tried already */
56 int redirects;
58 HttpReceiveFunc recv_func;
59 HttpAddHeaderFunc add_header_func;
60 HttpCloseFunc close_req_func;
61 HttpRedirectFunc redirect_func;
62 void *data;
64 } HttpRequest;
66 /*****************************************************************************/
68 HttpRequest *gt_http_request_new (const char *url,
69 const char *request);
70 void gt_http_request_close (HttpRequest *req, int code);
71 BOOL gt_http_url_parse (char *url, char **r_host,
72 char **r_path);
74 /*****************************************************************************/
76 void gt_http_request_set_conn (HttpRequest *req, TCPC *c);
77 void gt_http_request_set_proxy (HttpRequest *req, const char *proxy);
78 void gt_http_request_set_timeout (HttpRequest *req, time_t interval);
79 void gt_http_request_set_max_len (HttpRequest *req, size_t max_len);
81 /*****************************************************************************/
83 void gt_http_request_handle (int fd, input_id id, TCPC *c);
85 /*****************************************************************************/
87 #endif /* GIFT_GT_HTTP_REQUEST_H_ */