smb: fix use after free (cid #1348119)
[vlc.git] / include / vlc_http.h
blobb5ee726a48f6d75b27a8bae196696c0300d6ba9d
1 /*****************************************************************************
2 * vlc_http.h: Shared code for HTTP clients
3 *****************************************************************************
4 * Copyright (C) 2001-2008 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Christophe Massiot <massiot@via.ecp.fr>
9 * RĂ©mi Denis-Courmont <rem # videolan.org>
10 * Antoine Cellerier <dionoea at videolan dot org>
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation; either version 2.1 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this program; if not, write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 #ifndef VLC_HTTP_H
28 #define VLC_HTTP_H 1
30 /**
31 * \file
32 * This file defines functions, structures, enums and macros shared between
33 * HTTP clients.
36 #include <vlc_url.h>
37 #include <vlc_arrays.h>
39 /* RFC 2617: Basic and Digest Access Authentication */
40 typedef struct http_auth_t
42 char *psz_realm;
43 char *psz_domain;
44 char *psz_nonce;
45 char *psz_opaque;
46 char *psz_stale;
47 char *psz_algorithm;
48 char *psz_qop;
49 int i_nonce;
50 char *psz_cnonce;
51 char *psz_HA1; /* stored H(A1) value if algorithm = "MD5-sess" */
52 } http_auth_t;
55 VLC_API void http_auth_Init( http_auth_t * );
56 VLC_API void http_auth_Reset( http_auth_t * );
57 VLC_API void http_auth_ParseWwwAuthenticateHeader
58 ( vlc_object_t *, http_auth_t * ,
59 const char * );
60 VLC_API int http_auth_ParseAuthenticationInfoHeader
61 ( vlc_object_t *, http_auth_t *,
62 const char *, const char *,
63 const char *, const char *,
64 const char * );
65 VLC_API char *http_auth_FormatAuthorizationHeader
66 ( vlc_object_t *, http_auth_t *,
67 const char *, const char *,
68 const char *, const char * ) VLC_USED;
70 /* RFC 6265: cookies */
72 typedef struct vlc_http_cookie_jar_t vlc_http_cookie_jar_t;
74 VLC_API vlc_http_cookie_jar_t * vlc_http_cookies_new( void ) VLC_USED;
75 VLC_API void vlc_http_cookies_destroy( vlc_http_cookie_jar_t * p_jar );
77 /**
78 * Parse a value of an incoming Set-Cookie header and append the
79 * cookie to the cookie jar if appropriate.
81 * @param jar cookie jar object
82 * @param cookie header field value of Set-Cookie
83 * @return true, if the cookie was added, false otherwise
85 VLC_API bool vlc_http_cookies_store( vlc_http_cookie_jar_t *jar,
86 const char *cookie, bool secure, const char *host, const char *path );
88 VLC_API bool vlc_http_cookies_append( vlc_http_cookie_jar_t * p_jar, const char * psz_cookie_header, const vlc_url_t * p_url );
90 /**
91 * Returns a cookie value that match the given URL.
93 * @param p_jar a cookie jar
94 * @param p_url the URL for which the cookies are returned
95 * @return A string consisting of semicolon-separated cookie NAME=VALUE pairs.
97 VLC_API char *vlc_http_cookies_fetch( vlc_http_cookie_jar_t *jar, bool secure,
98 const char *host, const char *path );
100 VLC_API char *vlc_http_cookies_for_url( vlc_http_cookie_jar_t * p_jar, const vlc_url_t * p_url );
102 #endif /* VLC_HTTP_H */