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