e2k-http-utils

## e2k-http-utils e2k-http-utils — HTTP utility functions |

## Synopsis

    typedef     E2kHTTPStatus;
    #define     E2K_HTTP_STATUS_IS_TRANSPORT_ERROR(status)
    #define     E2K_HTTP_STATUS_IS_INFORMATIONAL(status)
    #define     E2K_HTTP_STATUS_IS_SUCCESSFUL   (status)
    #define     E2K_HTTP_STATUS_IS_REDIRECTION  (status)
    #define     E2K_HTTP_STATUS_IS_CLIENT_ERROR (status)
    #define     E2K_HTTP_STATUS_IS_SERVER_ERROR (status)

    time_t      e2k_http_parse_date             (const char *date);
    E2kHTTPStatus e2k_http_parse_status         (const char *status_line);
    const char* e2k_http_accept_language        (void);

## Description

## Details

### E2kHTTPStatus

    typedef unsigned int E2kHTTPStatus;

This represents a libsoup or HTTP status code

### E2K_HTTP_STATUS_IS_TRANSPORT_ERROR()

    #define E2K_HTTP_STATUS_IS_TRANSPORT_ERROR(status) SOUP_STATUS_IS_TRANSPORT_ERROR(status)

Tests if `status` indicates a libsoup error

`status` : | the status code
Returns : | `TRUE` if `status` indicates a libsoup error

### E2K_HTTP_STATUS_IS_INFORMATIONAL()

    #define E2K_HTTP_STATUS_IS_INFORMATIONAL(status)   SOUP_STATUS_IS_INFORMATIONAL(status)

Tests if `status` is an informational (1xx) response

`status` : | the status code
Returns : | `TRUE` if `status` is an informational response

### E2K_HTTP_STATUS_IS_SUCCESSFUL()

    #define E2K_HTTP_STATUS_IS_SUCCESSFUL(status)      SOUP_STATUS_IS_SUCCESSFUL(status)

Tests if `status` is a success (2xx) response

`status` : | the status code
Returns : | `TRUE` if `status` indicates success

### E2K_HTTP_STATUS_IS_REDIRECTION()

    #define E2K_HTTP_STATUS_IS_REDIRECTION(status)     SOUP_STATUS_IS_REDIRECTION(status)

Tests if `status` is a redirection (3xx) response

`status` : | the status code
Returns : | `TRUE` if `status` indicates a redirection

### E2K_HTTP_STATUS_IS_CLIENT_ERROR()

    #define E2K_HTTP_STATUS_IS_CLIENT_ERROR(status)    SOUP_STATUS_IS_CLIENT_ERROR(status)

Tests if `status` is a client error (4xx) response

`status` : | the status code
Returns : | `TRUE` if `status` indicates a client error

### E2K_HTTP_STATUS_IS_SERVER_ERROR()

    #define E2K_HTTP_STATUS_IS_SERVER_ERROR(status)    SOUP_STATUS_IS_SERVER_ERROR(status)

Tests if `status` is a server error (5xx) response

`status` : | the status code
Returns : | `TRUE` if `status` indicates a server error

### e2k_http_parse_date ()

    time_t      e2k_http_parse_date             (const char *date);

Converts an HTTP Date header into a time_t value. Doesn't do much sanity checking on the format since we know IIS always returns the date in RFC 1123 format, not either of the other two allowable formats.

`date` : | an HTTP Date header, returned from Exchange
Returns : | a `time_t` corresponding to `date`.

### e2k_http_parse_status ()

    E2kHTTPStatus e2k_http_parse_status         (const char *status_line);

Parses an HTTP Status-Line and returns the Status-Code

`status_line` : | an HTTP Status-Line
Returns : | the Status-Code portion of `status_line`

### e2k_http_accept_language ()

    const char* e2k_http_accept_language        (void);

Generates an Accept-Language value to send to the Exchange server. The user's default folders (Inbox, Calendar, etc) are not created until the user connects to Exchange for the first time, and in that case, it needs to know what language to name the folders in. libexchange users are responsible for setting the Accept-Language header on any request that could be the first-ever request to a mailbox. (Exchange will return 401 Unauthorized if it receives a request with no Accept-Language header for an uninitialized mailbox.)

Returns : | an Accept-Language string.