Back to index

avfs  1.0.1
Classes | Defines | Typedefs | Functions
http_request.h File Reference
#include <stdio.h>
#include "http_utils.h"
#include "string_utils.h"
#include "nsocket.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  http_request_hooks

Defines

#define HTTP_OK   (0)
#define HTTP_ERROR   (1) /* Generic error; use http_get_error(session) for message */
#define HTTP_LOOKUP   (3) /* Name lookup failed */
#define HTTP_AUTH   (4) /* User authentication failed on server */
#define HTTP_AUTHPROXY   (5) /* User authentication failed on proxy */
#define HTTP_SERVERAUTH   (6) /* Server authentication failed */
#define HTTP_PROXYAUTH   (7) /* Proxy authentication failed */
#define HTTP_CONNECT   (8) /* Could not connect to server */
#define HTTP_TIMEOUT   (9) /* Connection timed out */
#define HTTP_FAILED   (10) /* The precondition failed */
#define HTTP_RETRY   (101)
#define EOL   "\r\n"

Typedefs

typedef struct http_session_s
typedef struct http_req_s
typedef int(* http_use_proxy )(void *userdata, const char *scheme, const char *hostname)
typedef int(* http_request_auth )(void *userdata, const char *realm, const char *hostname, char **username, char **password)
typedef int(* http_accept_response )(void *userdata, http_req *req, http_status *st)
typedef void(* http_block_reader )(void *userdata, const char *buf, size_t len)
typedef void(* http_header_handler )(void *userdata, const char *value)

Functions

http_session * http_session_create (void)
int http_session_destroy (http_session *sess)
int http_session_server (http_session *sess, const char *hostname, int port)
int http_session_proxy (http_session *sess, const char *hostname, int port)
void http_session_decide_proxy (http_session *sess, http_use_proxy use_proxy, void *userdata)
void http_set_expect100 (http_session *sess, int use_expect100)
void http_set_persist (http_session *sess, int persist)
void http_set_secure_context (http_session *sess, nssl_context *ctx)
int http_set_secure (http_session *sess, int secure)
int http_set_request_secure_upgrade (http_session *sess, int req_upgrade)
int http_set_accept_secure_upgrade (http_session *sess, int acc_upgrade)
void http_set_useragent (http_session *sess, const char *product)
int http_version_pre_http11 (http_session *sess)
const char * http_get_server_hostport (http_session *sess)
const char * http_get_scheme (http_session *sess)
void http_set_server_auth (http_session *sess, http_request_auth callback, void *userdata)
void http_set_proxy_auth (http_session *sess, http_request_auth callback, void *userdata)
void http_set_error (http_session *sess, const char *errstring)
const char * http_get_error (http_session *sess)
void http_add_hooks (http_session *sess, const http_request_hooks *hooks, void *cookie)
void * http_get_hook_private (http_req *req, const char *id)
http_req * http_request_create (http_session *sess, const char *method, const char *uri)
void http_set_request_body_buffer (http_req *req, const char *buffer)
void http_set_request_body_stream (http_req *req, FILE *stream)
int http_accept_2xx (void *userdata, http_req *req, http_status *st)
void http_add_response_body_reader (http_req *req, http_accept_response accpt, http_block_reader rdr, void *userdata)
void http_add_response_header_handler (http_req *req, const char *name, http_header_handler hdl, void *userdata)
void http_add_response_header_catcher (http_req *req, http_header_handler hdl, void *userdata)
void http_duplicate_header (void *userdata, const char *value)
void http_handle_numeric_header (void *userdata, const char *value)
void http_add_request_header (http_req *req, const char *name, const char *value)
void http_print_request_header (http_req *req, const char *name, const char *format,...)
sbuffer http_get_request_headers (http_req *req)
int http_request_dispatch (http_req *req)
const http_statushttp_get_status (http_req *req)
void http_request_destroy (http_req *req)

Define Documentation

#define EOL   "\r\n"

Definition at line 47 of file http_request.h.

#define HTTP_AUTH   (4) /* User authentication failed on server */

Definition at line 36 of file http_request.h.

#define HTTP_AUTHPROXY   (5) /* User authentication failed on proxy */

Definition at line 37 of file http_request.h.

#define HTTP_CONNECT   (8) /* Could not connect to server */

Definition at line 40 of file http_request.h.

#define HTTP_ERROR   (1) /* Generic error; use http_get_error(session) for message */

Definition at line 34 of file http_request.h.

#define HTTP_FAILED   (10) /* The precondition failed */

Definition at line 42 of file http_request.h.

#define HTTP_LOOKUP   (3) /* Name lookup failed */

Definition at line 35 of file http_request.h.

#define HTTP_OK   (0)

Definition at line 33 of file http_request.h.

#define HTTP_PROXYAUTH   (7) /* Proxy authentication failed */

Definition at line 39 of file http_request.h.

#define HTTP_RETRY   (101)

Definition at line 45 of file http_request.h.

#define HTTP_SERVERAUTH   (6) /* Server authentication failed */

Definition at line 38 of file http_request.h.

#define HTTP_TIMEOUT   (9) /* Connection timed out */

Definition at line 41 of file http_request.h.


Typedef Documentation

typedef int(* http_accept_response)(void *userdata, http_req *req, http_status *st)

Definition at line 268 of file http_request.h.

typedef void(* http_block_reader)(void *userdata, const char *buf, size_t len)

Definition at line 276 of file http_request.h.

typedef void(* http_header_handler)(void *userdata, const char *value)

Definition at line 290 of file http_request.h.

typedef struct http_req_s

Definition at line 52 of file http_request.h.

typedef int(* http_request_auth)(void *userdata, const char *realm, const char *hostname, char **username, char **password)

Definition at line 196 of file http_request.h.

typedef struct http_session_s

Definition at line 51 of file http_request.h.

typedef int(* http_use_proxy)(void *userdata, const char *scheme, const char *hostname)

Definition at line 90 of file http_request.h.


Function Documentation

int http_accept_2xx ( void *  userdata,
http_req *  req,
http_status st 
)

Definition at line 498 of file http_request.c.

{
    return (st->klass == 2);
}
void http_add_hooks ( http_session *  sess,
const http_request_hooks hooks,
void *  cookie 
)

Definition at line 322 of file http_request.c.

{
    struct hook *hk = ne_malloc(sizeof(struct hook));
    hk->hooks = hooks;
    hk->private = private;
    hk->next = sess->hooks;
    sess->hooks = hk;
}
void http_add_request_header ( http_req *  req,
const char *  name,
const char *  value 
)

Definition at line 647 of file http_request.c.

{
    sbuffer_concat(req->headers, name, ": ", value, EOL, NULL);
}
void http_add_response_body_reader ( http_req *  req,
http_accept_response  accpt,
http_block_reader  rdr,
void *  userdata 
)

Definition at line 696 of file http_request.c.

{
    struct body_reader *new = ne_malloc(sizeof(struct body_reader));
    new->accept_response = acpt;
    new->handler = rdr;
    new->userdata = userdata;
    new->next = req->body_readers;
    req->body_readers = new;
}
void http_add_response_header_catcher ( http_req *  req,
http_header_handler  hdl,
void *  userdata 
)

Definition at line 685 of file http_request.c.

{
    struct header_handler *new = ne_calloc(sizeof  *new);
    new->handler = hdl;
    new->userdata = userdata;
    new->next = req->header_catchers;
    req->header_catchers = new;
}
void http_add_response_header_handler ( http_req *  req,
const char *  name,
http_header_handler  hdl,
void *  userdata 
)

Definition at line 672 of file http_request.c.

{
    struct header_handler *new = ne_calloc(sizeof *new);
    int hash;
    new->name = lower_string(name);
    new->handler = hdl;
    new->userdata = userdata;
    hash = hdr_hash(new->name);
    new->next = req->header_handlers[hash];
    req->header_handlers[hash] = new;
}

Here is the call graph for this function:

void http_duplicate_header ( void *  userdata,
const char *  value 
)

Definition at line 303 of file http_request.c.

{
    char **location = userdata;
    *location = ne_strdup(value);
}
const char* http_get_error ( http_session *  sess)

Definition at line 281 of file http_request.c.

                                               {
    return sess->error;
}
void* http_get_hook_private ( http_req *  req,
const char *  id 
)

Definition at line 332 of file http_request.c.

{
    struct hook_request *hk;

    for (hk = req->hook_store; hk != NULL; hk = hk->next) {
       if (strcasecmp(hk->hook->hooks->id, id) == 0) {
           return hk->cookie;
       }
    }

    return NULL;
}
sbuffer http_get_request_headers ( http_req *  req)

Definition at line 653 of file http_request.c.

{
    return req->headers;
}
const char* http_get_scheme ( http_session *  sess)

Definition at line 452 of file http_request.c.

{
    if (sess->use_secure) {
       return "https";
    } else {
       return "http";
    }
}
const char* http_get_server_hostport ( http_session *  sess)

Definition at line 448 of file http_request.c.

                                                         {
    return sess->server.hostport;
}
const http_status* http_get_status ( http_req *  req)

Definition at line 1543 of file http_request.c.

{
    return &(req->status);
}
void http_handle_numeric_header ( void *  userdata,
const char *  value 
)

Definition at line 309 of file http_request.c.

{
    int *location = userdata;
    *location = atoi(value);
}
void http_print_request_header ( http_req *  req,
const char *  name,
const char *  format,
  ... 
)

Definition at line 658 of file http_request.c.

{
    va_list params;
    char buf[BUFSIZ];
    
    va_start(params, format);
    vsnprintf(buf, BUFSIZ, format, params);
    va_end(params);
    
    sbuffer_concat(req->headers, name, ": ", buf, EOL, NULL);
}
http_req* http_request_create ( http_session *  sess,
const char *  method,
const char *  uri 
)

Definition at line 506 of file http_request.c.

{
    sbuffer real_uri;
    http_req *req = ne_calloc(sizeof(http_req));

    DEBUG(DEBUG_HTTP, "Creating request...\n");

    req->session = sess;
    req->headers = sbuffer_create();
    
    /* Add in the fixed headers */
    add_fixed_headers(req);

    /* Set the standard stuff */
    req->method = method;
    req->method_is_head = (strcmp(req->method, "HEAD") == 0);
    req->body = body_none;
    
    /* FIXME: the proxy_decider is broken if they called
     * http_session_proxy before http_session_server, since in that
     * case we have not done a name lookup on the session server.  */
    if (sess->have_proxy && sess->proxy_decider != NULL) {
       req->use_proxy = 
           (*sess->proxy_decider)(sess->proxy_decider_udata,
                               http_get_scheme(sess), sess->server.hostname);
    }
    else {
       req->use_proxy = sess->have_proxy;
    }

    if (sess->request_secure_upgrade == 1) {
       req->upgrade_to_tls = 1;
    }

    /* Add in standard callbacks */

    if (sess->server.auth_callback != NULL) {
       http_auth_set_creds_cb(&sess->server.auth, give_creds, req);
       http_add_response_body_reader(req, always_accept_response, 
                                  auth_body_reader, 
                                  &req->session->server.auth);
    }

    if (req->use_proxy && sess->proxy.auth_callback != NULL) {
       http_auth_set_creds_cb(&sess->proxy.auth, give_creds, req);
       http_add_response_body_reader(req, always_accept_response, 
                                  auth_body_reader, 
                                  &req->session->proxy.auth);
    }
    
    /* Add in handlers for all the standard HTTP headers. */

    http_add_response_header_handler(req, "Content-Length", 
                                  http_handle_numeric_header, &req->resp.length);
    http_add_response_header_handler(req, "Transfer-Encoding", 
                                  te_hdr_handler, &req->resp);
    http_add_response_header_handler(req, "Connection", 
                                  connection_hdr_handler, req);

    if (uri) {
       req->abs_path = ne_strdup(uri);
       real_uri = sbuffer_create();
       if (req->use_proxy)
           sbuffer_concat(real_uri, http_get_scheme(req->session), "://", 
                        req->session->server.hostport, NULL);
       sbuffer_zappend(real_uri, req->abs_path);
       req->uri = sbuffer_finish(real_uri);
    }

    {
       struct hook *hk;
       struct hook_request *store;
       void *cookie;

       DEBUG(DEBUG_HTTP, "Running request create hooks.\n");

       for (hk = sess->hooks; hk != NULL; hk = hk->next) {
           cookie = (*hk->hooks->create)(hk->private, req, method, uri);
           if (cookie != NULL) {
              store = ne_malloc(sizeof(struct hook_request));
              store->hook = hk;
              store->cookie = cookie;
              store->next = req->hook_store;
              req->hook_store = store;
           }
       }
    }

    DEBUG(DEBUG_HTTP, "Request created.\n");

    return req;
}

Here is the call graph for this function:

void http_request_destroy ( http_req *  req)

Definition at line 707 of file http_request.c.

{
    struct body_reader *rdr, *next_rdr;
    struct header_handler *hdlr, *next_hdlr;
    struct hook_request *st, *next_st;
    int n;

    HTTP_FREE(req->uri);
    HTTP_FREE(req->abs_path);

    for (rdr = req->body_readers; rdr != NULL; rdr = next_rdr) {
       next_rdr = rdr->next;
       free(rdr);
    }

    for (hdlr = req->header_catchers; hdlr != NULL; hdlr = next_hdlr) {
       next_hdlr = hdlr->next;
       free(hdlr);
    }

    for (n = 0; n < HH_HASHSIZE; n++) {
       for (hdlr = req->header_handlers[n]; hdlr != NULL; 
            hdlr = next_hdlr) {
           next_hdlr = hdlr->next;
           free(hdlr->name);
           free(hdlr);
       }
    }

    sbuffer_destroy(req->headers);

    DEBUG(DEBUG_HTTP, "Running destroy hooks.\n");
    for (st = req->hook_store; st!=NULL; st = next_st) {
       next_st = st->next;
       if (HAVE_HOOK(st,destroy)) {
           HOOK_FUNC(st,destroy)(st->cookie);
       }
       free(st);
    }

    DEBUG(DEBUG_HTTP, "Request ends.\n");
    free(req);
}

Here is the call graph for this function:

int http_request_dispatch ( http_req *  req)

Definition at line 1360 of file http_request.c.

{
    http_session *sess = req->session;
    sbuffer buf, request;
    int ret, attempt, proxy_attempt, con_attempt, can_retry;
    /* Response header storage */
    char *www_auth, *proxy_auth, *authinfo, *proxy_authinfo;
    http_status *status = &req->status;

    /* Initialization... */
    DEBUG(DEBUG_HTTP, "Request started...\n");
    http_set_error(sess, "Unknown error.");
    ret = HTTP_OK;

    if (get_request_bodysize(req))
       return HTTP_ERROR;

    buf = sbuffer_create_sized(BUFSIZ);

    if (sess->server.auth_callback != NULL) {
       http_add_response_header_handler(req, "WWW-Authenticate",
                                    http_duplicate_header, &www_auth);
       http_add_response_header_handler(req, "Authentication-Info",
                                    http_duplicate_header, &authinfo);
    }

    if (req->use_proxy && sess->proxy.auth_callback != NULL) {
       http_add_response_header_handler(req, "Proxy-Authenticate",
                                    http_duplicate_header, &proxy_auth);
       http_add_response_header_handler(req, "Proxy-Authentication-Info",
                                    http_duplicate_header, 
                                    &proxy_authinfo);
    }
                                 
    request = sbuffer_create();
    proxy_attempt = con_attempt = attempt = 1;
    www_auth = proxy_auth = authinfo = proxy_authinfo = NULL;
    
    /* Loop sending the request:
     * Retry whilst authentication fails and we supply it. */
    
    do {
       struct hook_request *st;
       
       can_retry = 0;
       req->can_persist = 0;
       req->forced_close = 0;

       build_request(req, request);

       DEBUG(DEBUG_HTTP, "Running pre_send hooks\n");
       for (st = req->hook_store; st!=NULL; st = st->next) {
           if (HAVE_HOOK(st,pre_send)) {
              HOOK_FUNC(st,pre_send)(st->cookie, request);
           }
       }                                             

       /* Final CRLF */
       sbuffer_zappend(request, EOL);
       
       /* Now send the request, and read the Status-Line */
       ret = send_request(req, sbuffer_data(request), buf);
       if (ret != HTTP_OK) goto dispatch_error;

       req->resp.length = -1;
       req->resp.is_chunked = 0;

       /* Read the headers */
       if (read_response_headers(req, buf) != HTTP_OK) {
           ret = HTTP_ERROR;
           goto dispatch_error;
       }

       normalize_response_length(req);

       ret = read_response_body(req);
       if (ret != HTTP_OK) goto dispatch_error;

       /* Read headers in chunked trailers */
       if (req->resp.is_chunked) {
           ret = read_response_headers(req, buf);
           if (ret != HTTP_OK) goto dispatch_error;
       }

       DEBUG(DEBUG_HTTP, "Running post_send hooks\n");
       for (st = req->hook_store; st!=NULL; st = st->next) {
           if (HAVE_HOOK(st,post_send)) {
              int hret = HOOK_FUNC(st,post_send)(st->cookie, status);
              /* TODO: this will simplify down to using just 'ret' once
               * we move authentication into hooks. */
              switch(hret) {
              case HTTP_OK:
                  break;
              case HTTP_RETRY:
                  can_retry = 1;
                  break;
              default:
                  /* They must set session error */
                  ret = hret;
              }
           }
       }

       if (proxy_authinfo != NULL && 
           http_auth_verify_response(&sess->proxy.auth, proxy_authinfo)) {
           DEBUG(DEBUG_HTTP, "Proxy response authentication invalid.\n");
           ret = HTTP_SERVERAUTH;
           http_set_error(sess, _("Proxy server was not authenticated correctly."));
       } else if (authinfo != NULL &&
                 http_auth_verify_response(&sess->server.auth, authinfo)) {
           DEBUG(DEBUG_HTTP, "Response authenticated as invalid.\n");
           ret = HTTP_PROXYAUTH;
           http_set_error(sess, _("Server was not authenticated correctly."));
       } else if (status->code == 401 && www_auth != NULL && attempt++ == 1) {
           if (!http_auth_challenge(&sess->server.auth, www_auth)) {
              can_retry = 1;
           }         
       } else if (status->code == 407 && proxy_auth != NULL && proxy_attempt++ == 1) {
           if (!http_auth_challenge(&sess->proxy.auth, proxy_auth)) {
              can_retry = 1;
           }
       }

       HTTP_FREE(www_auth);
       HTTP_FREE(proxy_auth);
       HTTP_FREE(authinfo);
       HTTP_FREE(proxy_authinfo);
       
       DEBUG(DEBUG_HTTP, "Connection status: %s, %s, %s\n",
             req->forced_close?"forced close":"no forced close",
             sess->no_persist?"no persistent connection":"persistent connection",
             HTTP_VERSION_PRE11(sess)?"pre-HTTP/1.1":"HTTP/1.1 or later");

       /* Close the connection if any of the following are true:
        *  - We have a forced close (e.g. "Connection: close" header)
        *  - We are not using persistent connections for this session
        *  - All of the following are true:
        *    * this is HTTP/1.0
        *    * and they haven't said they can do persistent connections 
        *    * we've not just done a successful CONNECT
        */
       if (req->forced_close || sess->no_persist ||
           (HTTP_VERSION_PRE11(sess) && 
            !req->can_persist && 
            (!sess->in_connect || status->klass != 2))) {
           close_connection(sess);
       }
    
       /* Retry it if we had an auth challenge */

    } while (can_retry);

    DEBUG(DEBUG_HTTP | DEBUG_FLUSH, 
          "Request ends, status %d class %dxx, error line:\n%s\n", 
          status->code, status->klass, sess->error);
    DEBUG(DEBUG_HTTPBASIC, "Response: %d %s", status->code, sess->error);

    if (ret == HTTP_OK) {
       switch(status->code) {
       case 401:
           ret = HTTP_AUTH;
           break;
       case 407:
           ret = HTTP_AUTHPROXY;
           break;
       default:
           break;
       }
    }

dispatch_error:
    
    sbuffer_destroy(request);
    sbuffer_destroy(buf);

    HTTP_FREE(www_auth);
    HTTP_FREE(proxy_auth);
    HTTP_FREE(authinfo);
    HTTP_FREE(proxy_authinfo);

    return ret;
}

Here is the call graph for this function:

http_session* http_session_create ( void  )

Definition at line 137 of file http_request.c.

{
    http_session *sess = ne_calloc(sizeof *sess);

    DEBUG(DEBUG_HTTP, "HTTP session begins.\n");
    strcpy(sess->error, "Unknown error.");
    sess->version_major = -1;
    sess->version_minor = -1;
    /* Default expect-100 to OFF. */
    sess->expect100_works = -1;
    return sess;
}
void http_session_decide_proxy ( http_session *  sess,
http_use_proxy  use_proxy,
void *  userdata 
)

Definition at line 241 of file http_request.c.

{
    sess->proxy_decider = use_proxy;
    sess->proxy_decider_udata = userdata;
}
int http_session_destroy ( http_session *  sess)

Definition at line 345 of file http_request.c.

{
    struct hook *hk;

    DEBUG(DEBUG_HTTP, "http_session_destroy called.\n");
    http_auth_finish(&sess->server.auth);
    if (sess->have_proxy) {
       http_auth_finish(&sess->proxy.auth);
    }
    HTTP_FREE(sess->server.hostname);
    HTTP_FREE(sess->server.hostport);
    HTTP_FREE(sess->proxy.hostport);
    HTTP_FREE(sess->user_agent);

    /* Clear the hooks. */
    hk = sess->hooks;
    while (hk) {
       struct hook *nexthk = hk->next;
       free(hk);
       hk = nexthk;
    }
       
    if (sess->connected) {
       close_connection(sess);
    }

    free(sess);
    return HTTP_OK;
}

Here is the call graph for this function:

int http_session_proxy ( http_session *  sess,
const char *  hostname,
int  port 
)

Definition at line 248 of file http_request.c.

{
    if (sess->connected) {
       /* Reconnect */
       close_connection(sess);
    }
    sess->have_proxy = 1;
    set_hostinfo(&sess->proxy, hostname, port);
    return lookup_host(&sess->proxy);
}

Here is the call graph for this function:

int http_session_server ( http_session *  sess,
const char *  hostname,
int  port 
)

Definition at line 188 of file http_request.c.

{
    if (sess->connected && !sess->have_proxy) {
       /* Reconnect */
       close_connection(sess);
    }
    set_hostinfo(&sess->server, hostname, port);
    /* We do a name lookup on the origin server if either:
     *  1) we do not have a proxy server
     *  2) we *might not* have a proxy server (since we have a 'proxy decider' function).
     */
    if (!sess->have_proxy || sess->proxy_decider) {
       return lookup_host(&sess->server);
    } else {
       return HTTP_OK;
    }
}

Here is the call graph for this function:

int http_set_accept_secure_upgrade ( http_session *  sess,
int  acc_upgrade 
)

Definition at line 221 of file http_request.c.

{
#ifdef ENABLE_SSL
    sess->accept_secure_upgrade = acc_upgrade;
    return 0;
#else
    return -1;
#endif
}
void http_set_error ( http_session *  sess,
const char *  errstring 
)

Definition at line 274 of file http_request.c.

{
    strncpy(sess->error, errstring, BUFSIZ);
    sess->error[BUFSIZ-1] = '\0';
    STRIP_EOL(sess->error);
}
void http_set_expect100 ( http_session *  sess,
int  use_expect100 
)

Definition at line 626 of file http_request.c.

{
    if (use_expect100) {
       sess->expect100_works = 1;
    } else {
       sess->expect100_works = -1;
    }
}
void http_set_persist ( http_session *  sess,
int  persist 
)

Definition at line 635 of file http_request.c.

{
    sess->no_persist = !persist;
}
void http_set_proxy_auth ( http_session *  sess,
http_request_auth  callback,
void *  userdata 
)

Definition at line 267 of file http_request.c.

{
    sess->proxy.auth_callback = callback;
    sess->proxy.auth_userdata = userdata;
}
void http_set_request_body_buffer ( http_req *  req,
const char *  buffer 
)

Definition at line 610 of file http_request.c.

{
    req->body = body_buffer;
    req->body_buffer = buffer;
    req->body_stream = NULL;
    run_set_body_hooks(req, buffer, NULL);
}

Here is the call graph for this function:

void http_set_request_body_stream ( http_req *  req,
FILE *  stream 
)

Definition at line 618 of file http_request.c.

{
    req->body = body_stream;
    req->body_stream = stream;
    req->body_buffer = NULL;
    run_set_body_hooks(req, NULL, stream);
}

Here is the call graph for this function:

int http_set_request_secure_upgrade ( http_session *  sess,
int  req_upgrade 
)

Definition at line 211 of file http_request.c.

{
#ifdef ENABLE_SSL
    sess->request_secure_upgrade = req_upgrade;
    return 0;
#else
    return -1;
#endif
}
int http_set_secure ( http_session *  sess,
int  secure 
)

Definition at line 231 of file http_request.c.

{
#ifdef ENABLE_SSL
    sess->use_secure = use_secure;
    return 0;
#else
    return -1;
#endif
}
void http_set_secure_context ( http_session *  sess,
nssl_context *  ctx 
)

Definition at line 206 of file http_request.c.

{
    sess->ssl_context = ctx;
}
void http_set_server_auth ( http_session *  sess,
http_request_auth  callback,
void *  userdata 
)

Definition at line 259 of file http_request.c.

{
    sess->server.auth_callback = callback;
    sess->server.auth_userdata = userdata;
}
void http_set_useragent ( http_session *  sess,
const char *  product 
)

Definition at line 640 of file http_request.c.

{
    static const char *fixed = " " NEON_USERAGENT;
    HTTP_FREE(sess->user_agent);
    CONCAT2(sess->user_agent, token, fixed);
}
int http_version_pre_http11 ( http_session *  sess)

Definition at line 183 of file http_request.c.

{
    return HTTP_VERSION_PRE11(sess);
}