Mercurial > hg > index.fcgi > gift-gnutella > gift-gnutella-0.0.11-1pba
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/http_request.h Sat Feb 20 21:18:28 2010 -0800 1.3 @@ -0,0 +1,87 @@ 1.4 +/* 1.5 + * $Id: http_request.h,v 1.11 2004/03/24 06:20:48 hipnod Exp $ 1.6 + * 1.7 + * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net) 1.8 + * 1.9 + * This program is free software; you can redistribute it and/or modify it 1.10 + * under the terms of the GNU General Public License as published by the 1.11 + * Free Software Foundation; either version 2, or (at your option) any 1.12 + * later version. 1.13 + * 1.14 + * This program is distributed in the hope that it will be useful, but 1.15 + * WITHOUT ANY WARRANTY; without even the implied warranty of 1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1.17 + * General Public License for more details. 1.18 + */ 1.19 + 1.20 +#ifndef GIFT_GT_HTTP_REQUEST_H_ 1.21 +#define GIFT_GT_HTTP_REQUEST_H_ 1.22 + 1.23 +/*****************************************************************************/ 1.24 + 1.25 +struct gt_http_request; 1.26 + 1.27 +/*****************************************************************************/ 1.28 + 1.29 +typedef void (*HttpCloseFunc) (struct gt_http_request *req, int error_code); 1.30 + 1.31 +typedef BOOL (*HttpReceiveFunc) (struct gt_http_request *req, char *data, 1.32 + size_t len); 1.33 +typedef BOOL (*HttpAddHeaderFunc) (struct gt_http_request *req, 1.34 + Dataset **headers); 1.35 +typedef BOOL (*HttpRedirectFunc) (struct gt_http_request *req, 1.36 + const char *host, const char *path); 1.37 + 1.38 +/*****************************************************************************/ 1.39 + 1.40 +typedef struct gt_http_request 1.41 +{ 1.42 + char *host; 1.43 + char *path; 1.44 + char *request; 1.45 + char *proxy; 1.46 + 1.47 + TCPC *c; 1.48 + Dataset *headers; 1.49 + timer_id timeout; 1.50 + 1.51 + /* amount of data to expect: 1.52 + * (1) in the chunk, when Transfer-Encoding: Chunked is used 1.53 + * (2) in the body, from the Content-Length: header */ 1.54 + unsigned long size; 1.55 + size_t max_len; 1.56 + size_t recvd_len; 1.57 + 1.58 + /* number of redirects tried already */ 1.59 + int redirects; 1.60 + 1.61 + HttpReceiveFunc recv_func; 1.62 + HttpAddHeaderFunc add_header_func; 1.63 + HttpCloseFunc close_req_func; 1.64 + HttpRedirectFunc redirect_func; 1.65 + void *data; 1.66 + 1.67 +} HttpRequest; 1.68 + 1.69 +/*****************************************************************************/ 1.70 + 1.71 +HttpRequest *gt_http_request_new (const char *url, 1.72 + const char *request); 1.73 +void gt_http_request_close (HttpRequest *req, int code); 1.74 +BOOL gt_http_url_parse (char *url, char **r_host, 1.75 + char **r_path); 1.76 + 1.77 +/*****************************************************************************/ 1.78 + 1.79 +void gt_http_request_set_conn (HttpRequest *req, TCPC *c); 1.80 +void gt_http_request_set_proxy (HttpRequest *req, const char *proxy); 1.81 +void gt_http_request_set_timeout (HttpRequest *req, time_t interval); 1.82 +void gt_http_request_set_max_len (HttpRequest *req, size_t max_len); 1.83 + 1.84 +/*****************************************************************************/ 1.85 + 1.86 +void gt_http_request_handle (int fd, input_id id, TCPC *c); 1.87 + 1.88 +/*****************************************************************************/ 1.89 + 1.90 +#endif /* GIFT_GT_HTTP_REQUEST_H_ */