source: trunk/third/libghttp/ghttp.h @ 15592

Revision 15592, 5.4 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r15591, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * ghttp.h -- A public interface to common http functions
3 * Created: Christopher Blizzard <blizzard@appliedtheory.com>, 21-Aug-1998
4 *
5 * Copyright (C) 1998 Free Software Foundation
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#ifndef GHTTP_H
23#define GHTTP_H
24
25#include <ghttp_constants.h>
26#include <time.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif /* __cplusplus */
31
32typedef struct _ghttp_request ghttp_request;
33
34typedef enum ghttp_type_tag
35{
36  ghttp_type_get = 0,
37  ghttp_type_options,
38  ghttp_type_head,
39  ghttp_type_post,
40  ghttp_type_put,
41  ghttp_type_delete,
42  ghttp_type_trace,
43  ghttp_type_connect,
44  ghttp_type_propfind,
45  ghttp_type_proppatch,
46  ghttp_type_mkcol,
47  ghttp_type_copy,
48  ghttp_type_move,
49  ghttp_type_lock,
50  ghttp_type_unlock
51} ghttp_type;
52
53typedef enum ghttp_sync_mode_tag
54{
55  ghttp_sync = 0,
56  ghttp_async
57} ghttp_sync_mode;
58
59typedef enum ghttp_status_tag
60{
61  ghttp_error = -1,
62  ghttp_not_done,
63  ghttp_done
64} ghttp_status;
65
66typedef enum ghttp_proc_tag
67{
68  ghttp_proc_none = 0,
69  ghttp_proc_request,
70  ghttp_proc_response_hdrs,
71  ghttp_proc_response
72} ghttp_proc;
73
74typedef struct ghttp_current_status_tag
75{
76  ghttp_proc         proc;        /* what's it doing? */
77  int                bytes_read;  /* how many bytes have been read? */
78  int                bytes_total; /* how many total */
79} ghttp_current_status;
80
81/* create a new request object */
82ghttp_request *
83ghttp_request_new(void);
84
85/* delete a current request object */
86void
87ghttp_request_destroy(ghttp_request *a_request);
88
89/* Validate a uri
90 * This will return -1 if a uri is invalid
91 */
92int
93ghttp_uri_validate(char *a_uri);
94
95/* Set a uri in a request
96 * This will return -1 if the uri is invalid
97 */
98
99int
100ghttp_set_uri(ghttp_request *a_request, char *a_uri);
101
102/* Set a proxy for a request
103 * This will return -1 if the uri is invalid
104 */
105
106int
107ghttp_set_proxy(ghttp_request *a_request, char *a_uri);
108
109/* Set a request type
110 * This will return -1 if the request type is invalid or
111 * unsupported
112 */
113
114int
115ghttp_set_type(ghttp_request *a_request, ghttp_type a_type);
116
117/* Set the body.
118 * This will return -1 if the request type doesn't support it
119 */
120
121int
122ghttp_set_body(ghttp_request *a_request, char *a_body, int a_len);
123
124/* Set whether or not you want to use sync or async mode.
125 */
126
127int
128ghttp_set_sync(ghttp_request *a_request,
129               ghttp_sync_mode a_mode);
130
131/* Prepare a request.
132 * Call this before trying to process a request or if you change the
133 * uri.
134 */
135
136int
137ghttp_prepare(ghttp_request *a_request);
138
139/* Set the chunk size
140 * You might want to do this to optimize for different connection speeds.
141 */
142
143void
144ghttp_set_chunksize(ghttp_request *a_request, int a_size);
145
146/* Set a random request header
147 */
148
149void
150ghttp_set_header(ghttp_request *a_request,
151                 const char *a_hdr, const char *a_val);
152
153/* Process a request
154 */
155
156ghttp_status
157ghttp_process(ghttp_request *a_request);
158
159/* Get the status of a request
160 */
161
162ghttp_current_status
163ghttp_get_status(ghttp_request *a_request);
164
165/* Flush the received data (so far) into the response body.  This is
166 * useful for asynchronous requests with large responses: you can
167 * periodically flush the response buffer and parse the data that's
168 * arrived so far.
169 */
170
171void
172ghttp_flush_response_buffer(ghttp_request *a_request);
173
174/* Get the value of a random response header
175 */
176
177const char *
178ghttp_get_header(ghttp_request *a_request,
179                 const char *a_hdr);
180
181/* Get the list of headers that were returned in the response.  You
182   must free the returned string values.  This function will return 0
183   on success, -1 on some kind of error. */
184int
185ghttp_get_header_names(ghttp_request *a_request,
186                       char ***a_hdrs, int *a_num_hdrs);
187
188/* Abort a currently running request.  */
189int
190ghttp_close(ghttp_request *a_request);
191
192/* Clean a request
193 */
194void
195ghttp_clean(ghttp_request *a_request);
196
197/* Get the socket associated with a particular connection
198 */
199
200int
201ghttp_get_socket(ghttp_request *a_request);
202
203/* get the return entity body
204 */
205
206char *
207ghttp_get_body(ghttp_request *a_request);
208
209/* get the returned length
210 */
211
212int
213ghttp_get_body_len(ghttp_request *a_request);
214
215/* Get an error message for a request that has failed.
216 */
217
218const char *
219ghttp_get_error(ghttp_request *a_request);
220
221/* Parse a date string that is one of the standard
222 * date formats
223 */
224
225time_t
226ghttp_parse_date(char *a_date);
227
228/* Return the status code.
229 */
230
231int
232ghttp_status_code(ghttp_request *a_request);
233
234/* Return the reason phrase.
235 */
236
237const char *
238ghttp_reason_phrase(ghttp_request *a_request);
239
240/* Set your username/password pair
241 */
242
243int
244ghttp_set_authinfo(ghttp_request *a_request,
245                   const char *a_user,
246                   const char *a_pass);
247                   
248
249 /* Set your username/password pair for proxy
250  */
251 
252int
253ghttp_set_proxy_authinfo(ghttp_request *a_request,
254                         const char *a_user,
255                         const char *a_pass);
256
257
258#ifdef __cplusplus
259}
260#endif /* __cplusplus */
261
262
263#endif /* GHTTP_H */
Note: See TracBrowser for help on using the repository browser.