source: lib/http_client.h @ 7f4016b

Last change on this file since 7f4016b was 0aaca60, checked in by Wilmer van der Gaast <wilmer@…>, at 2006-07-19T16:52:38Z

Added some (more) comments to .h files in lib/ and some minor fixes/cleanups.

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[8a9afe4]1  /********************************************************************\
2  * BitlBee -- An IRC to other IM-networks gateway                     *
3  *                                                                    *
4  * Copyright 2002-2005 Wilmer van der Gaast and others                *
5  \********************************************************************/
6
[7c0a497]7/* HTTP(S) module                                                       */
[8a9afe4]8
9/*
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License with
21  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
22  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23  Suite 330, Boston, MA  02111-1307  USA
24*/
25
[0aaca60]26/* http_client allows you to talk (asynchronously, again) to HTTP servers.
27   In the "background" it will send the whole query and wait for a complete
28   response to come back. Right now it's only used by the MSN Passport
29   authentication code, but it might be useful for other things too (for
30   example the AIM usericon patch uses this so icons can be stored on
31   webservers instead of the local filesystem).
32   
33   Didn't test this too much, but it seems to work well. Just don't look
34   at the code that handles HTTP 30x redirects. ;-) The function is
35   probably not very useful for downloading lots of data since it keeps
36   everything in a memory buffer until the download is completed (and
37   can't pass any data or whatever before then). It's very useful for
38   doing quick requests without blocking the whole program, though. */
[8a9afe4]39
[0aaca60]40#include <glib.h>
[8a9afe4]41#include "ssl_client.h"
42
43struct http_request;
44
[0aaca60]45/* Your callback function should look like this: */
[8a9afe4]46typedef void (*http_input_function)( struct http_request * );
47
[0aaca60]48/* This structure will be filled in by the http_dorequest* functions, and
49   it will be passed to the callback function. Use the data field to add
50   your own data. */
[8a9afe4]51struct http_request
52{
[0aaca60]53        char *request;          /* The request to send to the server. */
54        int request_length;     /* Its size. */
55        int status_code;        /* The numeric HTTP status code. (Or -1
56                                   if something really went wrong) */
57        char *status_string;    /* The error text. */
[8a9afe4]58        char *reply_headers;
59        char *reply_body;
[0aaca60]60        int body_size;          /* The number of bytes in reply_body. */
61        int finished;           /* Set to non-0 if the request was completed
62                                   successfully. */
63       
64        http_input_function func;
65        gpointer data;
66       
67        /* Please don't touch the things down here, you shouldn't need them. */
[8a9afe4]68       
69        void *ssl;
70        int fd;
71       
72        int inpa;
73        int bytes_written;
74        int bytes_read;
75};
76
[0aaca60]77/* The _url variant is probably more useful than the raw version. The raw
78   version is probably only useful if you want to do POST requests or if
79   you want to add some extra headers. As you can see, HTTPS connections
80   are also supported (using ssl_client). */
[f3e1e92]81void *http_dorequest( char *host, int port, int ssl, char *request, http_input_function func, gpointer data );
[0790644]82void *http_dorequest_url( char *url_string, http_input_function func, gpointer data );
Note: See TracBrowser for help on using the repository browser.