Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/http_client.c

    r1b5ab36 rba9edaa  
    3232
    3333
    34 static void http_connected( gpointer data, int source, GaimInputCondition cond );
    35 static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond );
    36 static void http_incoming_data( gpointer data, int source, GaimInputCondition cond );
     34static gboolean http_connected( gpointer data, int source, b_input_condition cond );
     35static gboolean http_ssl_connected( gpointer data, void *source, b_input_condition cond );
     36static gboolean http_incoming_data( gpointer data, int source, b_input_condition cond );
    3737
    3838
     
    7171}
    7272
    73 void *http_dorequest_url( char *url_string, http_input_function func, gpointer data )
    74 {
    75         url_t *url = g_new0( url_t, 1 );
    76         char *request;
    77         void *ret;
    78        
    79         if( !url_set( url, url_string ) )
    80         {
    81                 g_free( url );
    82                 return NULL;
    83         }
    84        
    85         if( url->proto != PROTO_HTTP && url->proto != PROTO_HTTPS )
    86         {
    87                 g_free( url );
    88                 return NULL;
    89         }
    90        
    91         request = g_strdup_printf( "GET %s HTTP/1.0\r\n"
    92                                    "Host: %s\r\n"
    93                                    "User-Agent: BitlBee " BITLBEE_VERSION " " ARCH "/" CPU "\r\n"
    94                                    "\r\n", url->file, url->host );
    95        
    96         ret = http_dorequest( url->host, url->port,
    97                               url->proto == PROTO_HTTPS, request, func, data );
    98        
    99         g_free( url );
    100         g_free( request );
    101         return ret;
    102 }
    103 
    10473/* This one is actually pretty simple... Might get more calls if we can't write
    10574   the whole request at once. */
    106 static void http_connected( gpointer data, int source, GaimInputCondition cond )
     75static gboolean http_connected( gpointer data, int source, b_input_condition cond )
    10776{
    10877        struct http_request *req = data;
     
    11382       
    11483        if( req->inpa > 0 )
    115                 gaim_input_remove( req->inpa );
     84                b_event_remove( req->inpa );
    11685       
    11786        sock_make_nonblocking( req->fd );
     
    148117       
    149118        if( req->bytes_written < req->request_length )
    150                 req->inpa = gaim_input_add( source,
    151                                             req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_WRITE,
    152                                             http_connected, req );
    153         else
    154                 req->inpa = gaim_input_add( source, GAIM_INPUT_READ, http_incoming_data, req );
    155        
    156         return;
     119                req->inpa = b_input_add( source,
     120                                         req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_WRITE,
     121                                         http_connected, req );
     122        else
     123                req->inpa = b_input_add( source, GAIM_INPUT_READ, http_incoming_data, req );
     124       
     125        return FALSE;
    157126       
    158127error:
     
    162131        g_free( req );
    163132       
    164         return;
     133        return FALSE;
    165134}
    166135
    167 static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond )
     136static gboolean http_ssl_connected( gpointer data, void *source, b_input_condition cond )
    168137{
    169138        struct http_request *req = data;
     
    177146}
    178147
    179 static void http_incoming_data( gpointer data, int source, GaimInputCondition cond )
     148static gboolean http_incoming_data( gpointer data, int source, b_input_condition cond )
    180149{
    181150        struct http_request *req = data;
     
    186155       
    187156        if( req->inpa > 0 )
    188                 gaim_input_remove( req->inpa );
     157                b_event_remove( req->inpa );
    189158       
    190159        if( req->ssl )
     
    233202       
    234203        /* There will be more! */
    235         req->inpa = gaim_input_add( req->fd,
    236                                     req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_READ,
    237                                     http_incoming_data, req );
    238        
    239         return;
     204        req->inpa = b_input_add( req->fd,
     205                                 req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_READ,
     206                                 http_incoming_data, req );
     207       
     208        return FALSE;
    240209
    241210got_reply:
     
    253222                evil_server = 1;
    254223        }
    255         else if( end1 )
     224        else
    256225        {
    257226                end1 += 2;
    258227        }
    259         else
    260         {
    261                 goto cleanup;
    262         }
    263        
    264         *end1 = 0;
    265        
    266         if( evil_server )
    267                 req->reply_body = end1 + 1;
    268         else
    269                 req->reply_body = end1 + 2;
    270        
    271         req->body_size = req->reply_headers + req->bytes_read - req->reply_body;
     228       
     229        if( end1 )
     230        {
     231                *end1 = 0;
     232               
     233                if( evil_server )
     234                        req->reply_body = end1 + 1;
     235                else
     236                        req->reply_body = end1 + 2;
     237        }
    272238       
    273239        if( ( end1 = strchr( req->reply_headers, ' ' ) ) != NULL )
     
    396362                req->reply_headers = req->reply_body = NULL;
    397363               
    398                 return;
     364                return FALSE;
    399365        }
    400366       
     
    414380        g_free( req->reply_headers );
    415381        g_free( req );
     382       
     383        return FALSE;
    416384}
Note: See TracChangeset for help on using the changeset viewer.