Changeset 0aaca60 for lib/http_client.h


Ignore:
Timestamp:
2006-07-19T16:52:38Z (19 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d3a672c
Parents:
04026d4
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/http_client.h

    r04026d4 r0aaca60  
    2424*/
    2525
     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. */
     39
    2640#include <glib.h>
    27 
    2841#include "ssl_client.h"
    2942
    3043struct http_request;
    3144
     45/* Your callback function should look like this: */
    3246typedef void (*http_input_function)( struct http_request * );
    3347
     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. */
    3451struct http_request
    3552{
    36         char *request;
    37         int request_length;
    38         int status_code;
    39         char *status_string;
     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. */
    4058        char *reply_headers;
    4159        char *reply_body;
    42         int body_size;
    43         int finished;
     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. */
    4468       
    4569        void *ssl;
     
    4973        int bytes_written;
    5074        int bytes_read;
    51        
    52         http_input_function func;
    53         gpointer data;
    5475};
    5576
     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). */
    5681void *http_dorequest( char *host, int port, int ssl, char *request, http_input_function func, gpointer data );
    5782void *http_dorequest_url( char *url_string, http_input_function func, gpointer data );
Note: See TracChangeset for help on using the changeset viewer.