Ignore:
Timestamp:
Sep 27, 2010 8:35:08 AM (14 years ago)
Author:
bennylp
Message:

Implemented and closed #1136: added HTTP authentication support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/include/pjlib-util/http_client.h

    r3227 r3321  
    5050 
    5151/** 
     52 * HTTP header representation. 
     53 */ 
     54typedef struct pj_http_header_elmt 
     55{ 
     56    pj_str_t name;      /**< Header name */ 
     57    pj_str_t value;     /**< Header value */ 
     58} pj_http_header_elmt; 
     59 
     60/** 
    5261 * This structure describes http request/response headers. 
    5362 * Application should call #pj_http_headers_add_elmt() to 
     
    5665typedef struct pj_http_headers 
    5766{ 
    58     unsigned     count;                   /**< Number of header fields */ 
    59     struct pj_http_header_elmt 
    60     { 
    61         pj_str_t name; 
    62         pj_str_t value; 
    63     } header[PJ_HTTP_HEADER_SIZE];        /**< Header elements/fields */ 
     67    /**< Number of header fields */ 
     68    unsigned     count; 
     69 
     70    /** Header elements/fields */ 
     71    pj_http_header_elmt header[PJ_HTTP_HEADER_SIZE]; 
    6472} pj_http_headers; 
     73 
     74/** 
     75 * Structure to save HTTP authentication credential. 
     76 */ 
     77typedef struct pj_http_auth_cred 
     78{ 
     79    /** 
     80     * Specify specific authentication schemes to be responded. Valid values 
     81     * are "basic" and "digest". If this field is not set, any authentication 
     82     * schemes will be responded. 
     83     * 
     84     * Default is empty. 
     85     */ 
     86    pj_str_t    scheme; 
     87 
     88    /** 
     89     * Specify specific authentication realm to be responded. If this field 
     90     * is set, only 401/407 response with matching realm will be responded. 
     91     * If this field is not set, any realms will be responded. 
     92     * 
     93     * Default is empty. 
     94     */ 
     95    pj_str_t    realm; 
     96 
     97    /** 
     98     * Specify authentication username. 
     99     * 
     100     * Default is empty. 
     101     */ 
     102    pj_str_t    username; 
     103 
     104    /** 
     105     * The type of password in \a data field. Currently only 0 is 
     106     * supported, meaning the \a data contains plain-text password. 
     107     * 
     108     * Default is 0. 
     109     */ 
     110    unsigned    data_type; 
     111 
     112    /** 
     113     * Specify authentication password. The encoding of the password depends 
     114     * on the value of \a data_type field above. 
     115     * 
     116     * Default is empty. 
     117     */ 
     118    pj_str_t    data; 
     119 
     120} pj_http_auth_cred; 
     121 
    65122 
    66123/** 
     
    126183                                   /**< will be provided later  */ 
    127184    } reqdata; 
     185 
     186    /** 
     187     * Authentication credential needed to respond to 401/407 response. 
     188     */ 
     189    pj_http_auth_cred   auth_cred; 
     190 
    128191} pj_http_req_param; 
     192 
     193/** 
     194 * HTTP authentication challenge, parsed from WWW-Authenticate header. 
     195 */ 
     196typedef struct pj_http_auth_chal 
     197{ 
     198    pj_str_t    scheme;         /**< Auth scheme.               */ 
     199    pj_str_t    realm;          /**< Realm for the challenge.   */ 
     200    pj_str_t    domain;         /**< Domain.                    */ 
     201    pj_str_t    nonce;          /**< Nonce challenge.           */ 
     202    pj_str_t    opaque;         /**< Opaque value.              */ 
     203    int         stale;          /**< Stale parameter.           */ 
     204    pj_str_t    algorithm;      /**< Algorithm parameter.       */ 
     205    pj_str_t    qop;            /**< Quality of protection.     */ 
     206} pj_http_auth_chal; 
    129207 
    130208/** 
     
    137215    pj_str_t        reason;         /**< Reason phrase */ 
    138216    pj_http_headers headers;        /**< Response headers */ 
    139     /** 
    140      * The value of content-length header field. -1 if not 
    141      * specified. 
    142      */ 
    143     pj_int32_t      content_length;  
     217    pj_http_auth_chal auth_chal;    /**< Parsed WWW-Authenticate header, if 
     218                                         any. */ 
     219    pj_int32_t      content_length; /**< The value of content-length header 
     220                                         field. -1 if not specified. */ 
    144221    void            *data;          /**< Data received */ 
    145222    pj_size_t       size;           /**< Data size */ 
     
    151228typedef struct pj_http_url 
    152229{ 
     230    pj_str_t    username;           /**< Username part */ 
     231    pj_str_t    passwd;             /**< Password part */ 
    153232    pj_str_t    protocol;           /**< Protocol used */ 
    154233    pj_str_t    host;               /**< Host name */ 
Note: See TracChangeset for help on using the changeset viewer.