vlc_http.h 3.46 KB
Newer Older
1 2 3
/*****************************************************************************
 * vlc_http.h: Shared code for HTTP clients
 *****************************************************************************
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
4
 * Copyright (C) 2001-2008 VLC authors and VideoLAN
5 6 7 8 9 10 11
 * $Id$
 *
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
 *          Christophe Massiot <massiot@via.ecp.fr>
 *          Rémi Denis-Courmont <rem # videolan.org>
 *          Antoine Cellerier <dionoea at videolan dot org>
 *
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
12 13 14
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
15 16 17 18
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
19 20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
21
 *
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
22 23 24
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 26 27 28 29 30 31 32 33 34 35
 *****************************************************************************/

#ifndef VLC_HTTP_H
#define VLC_HTTP_H 1

/**
 * \file
 * This file defines functions, structures, enums and macros shared between
 * HTTP clients.
 */

36 37 38
#include <vlc_url.h>
#include <vlc_arrays.h>

39
/* RFC 2617: Basic and Digest Access Authentication */
40
typedef struct vlc_http_auth_t
41 42 43 44 45 46 47 48 49 50 51
{
    char *psz_realm;
    char *psz_domain;
    char *psz_nonce;
    char *psz_opaque;
    char *psz_stale;
    char *psz_algorithm;
    char *psz_qop;
    int i_nonce;
    char *psz_cnonce;
    char *psz_HA1; /* stored H(A1) value if algorithm = "MD5-sess" */
52
} vlc_http_auth_t;
53 54


55
VLC_API void vlc_http_auth_Init( vlc_http_auth_t * );
56
VLC_API void vlc_http_auth_Deinit( vlc_http_auth_t * );
57 58 59 60
VLC_API void vlc_http_auth_ParseWwwAuthenticateHeader
            ( vlc_object_t *, vlc_http_auth_t * , const char * );
VLC_API int vlc_http_auth_ParseAuthenticationInfoHeader
            ( vlc_object_t *, vlc_http_auth_t *,
61 62
              const char *, const char *,
              const char *, const char *,
63
              const char * );
64 65
VLC_API char *vlc_http_auth_FormatAuthorizationHeader
            ( vlc_object_t *, vlc_http_auth_t *,
66
              const char *, const char *,
67
              const char *, const char * ) VLC_USED;
68

69 70
/* RFC 6265: cookies */

71
typedef struct vlc_http_cookie_jar_t vlc_http_cookie_jar_t;
72 73 74 75 76 77 78 79

VLC_API vlc_http_cookie_jar_t * vlc_http_cookies_new( void ) VLC_USED;
VLC_API void vlc_http_cookies_destroy( vlc_http_cookie_jar_t * p_jar );

/**
 * Parse a value of an incoming Set-Cookie header and append the
 * cookie to the cookie jar if appropriate.
 *
80 81
 * @param jar cookie jar object
 * @param cookie header field value of Set-Cookie
82 83
 * @return true, if the cookie was added, false otherwise
 */
84
VLC_API bool vlc_http_cookies_store( vlc_http_cookie_jar_t *jar,
85
    const char *cookie, const char *host, const char *path );
86

87 88 89
/**
 * Returns a cookie value that match the given URL.
 *
90 91
 * @param p_jar a cookie jar
 * @param p_url the URL for which the cookies are returned
92 93
 * @return A string consisting of semicolon-separated cookie NAME=VALUE pairs.
 */
94 95 96
VLC_API char *vlc_http_cookies_fetch( vlc_http_cookie_jar_t *jar, bool secure,
                                      const char *host, const char *path );

97
#endif /* VLC_HTTP_H */