VLC  3.0.15
connmgr.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * connmgr.h: HTTP/TLS VLC connection manager declaration
3  *****************************************************************************
4  * Copyright © 2015 Rémi Denis-Courmont
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20 
21 /**
22  * \defgroup http HTTP
23  * Hyper-Text Transfer Protocol
24  * \defgroup http_connmgr Connection manager
25  * HTTP connection management
26  * \ingroup http
27  * @{
28  * \file connmgr.h
29  */
30 
31 struct vlc_http_mgr;
32 struct vlc_http_msg;
34 
35 /**
36  * Sends an HTTP request
37  *
38  * Sends an HTTP request, by either reusing an existing HTTP connection or
39  * establishing a new one. If succesful, the initial HTTP response header is
40  * returned.
41  *
42  * @param mgr HTTP connection manager
43  * @param https whether to use HTTPS (true) or unencrypted HTTP (false)
44  * @param host name of authoritative HTTP server to send the request to
45  * @param port TCP server port number, or 0 for the default port number
46  * @param req HTTP request header to send
47  *
48  * @return The initial HTTP response header, or NULL in case of failure.
49  */
50 struct vlc_http_msg *vlc_http_mgr_request(struct vlc_http_mgr *mgr, bool https,
51  const char *host, unsigned port,
52  const struct vlc_http_msg *req);
53 
55 
56 /**
57  * Creates an HTTP connection manager
58  *
59  * Allocates an HTTP client connections manager.
60  *
61  * @param obj parent VLC object
62  * @param jar HTTP cookies jar (NULL to disable cookies)
63  */
65  struct vlc_http_cookie_jar_t *jar);
66 
67 /**
68  * Destroys an HTTP connection manager
69  *
70  * Deallocates an HTTP client connections manager created by
71  * vlc_http_msg_destroy(). Any remaining connection is closed and destroyed.
72  */
73 void vlc_http_mgr_destroy(struct vlc_http_mgr *mgr);
74 
75 /** @} */
vlc_h2_conn_create
struct vlc_http_conn * vlc_h2_conn_create(void *ctx, struct vlc_tls *)
Definition: h2conn.c:719
vlc_http_mgr_request
struct vlc_http_msg * vlc_http_mgr_request(struct vlc_http_mgr *mgr, bool https, const char *host, unsigned port, const struct vlc_http_msg *m)
Sends an HTTP request.
Definition: connmgr.c:254
vlc_tls_creds
TLS credentials.
Definition: vlc_tls.h:67
vlc_common.h
vlc_vaLog
void vlc_vaLog(vlc_object_t *obj, int type, const char *module, const char *file, unsigned line, const char *func, const char *format, va_list args)
Emit a log message.
Definition: messages.c:87
vlc_http_mgr::creds
vlc_tls_creds_t * creds
Definition: connmgr.c:98
vlc_http_mgr_reuse
static struct vlc_http_msg * vlc_http_mgr_reuse(struct vlc_http_mgr *mgr, const char *host, unsigned port, const struct vlc_http_msg *req)
Definition: connmgr.c:120
vlc_network.h
vlc_http_mgr
Definition: connmgr.c:95
vlc_http_mgr_create
struct vlc_http_mgr * vlc_http_mgr_create(vlc_object_t *obj, struct vlc_http_cookie_jar_t *jar)
Creates an HTTP connection manager.
Definition: connmgr.c:266
vlc_getProxyUrl
char * vlc_getProxyUrl(const char *url)
Determines the network proxy server to use (if any).
Definition: specific.c:315
vlc_h1_conn_create
struct vlc_http_conn * vlc_h1_conn_create(void *ctx, struct vlc_tls *, bool proxy)
Definition: h1conn.c:322
vlc_https_connect_proxy
struct vlc_tls * vlc_https_connect_proxy(void *ctx, struct vlc_tls_creds *creds, const char *name, unsigned port, bool *restrict two, const char *proxy)
Definition: tunnel.c:135
vlc_tls
Transport layer socket.
Definition: vlc_tls.h:43
vlc_http_mgr_release
static void vlc_http_mgr_release(struct vlc_http_mgr *mgr, struct vlc_http_conn *conn)
Definition: connmgr.c:110
vlc_UrlClean
void vlc_UrlClean(vlc_url_t *restrict url)
Definition: url.c:594
vlc_UrlParse
int vlc_UrlParse(vlc_url_t *url, const char *str)
Parses an URI or IRI.
Definition: url.c:554
vlc_http_request
static struct vlc_http_msg * vlc_http_request(struct vlc_http_mgr *mgr, const char *host, unsigned port, const struct vlc_http_msg *req)
Definition: connmgr.c:205
VLC_MSG_ERR
Error.
Definition: vlc_messages.h:47
vlc_h1_request
struct vlc_http_stream * vlc_h1_request(void *ctx, const char *hostname, unsigned port, bool proxy, const struct vlc_http_msg *req, bool idempotent, struct vlc_http_conn **restrict connp)
Sends an HTTP/1.x request through a new connection.
Definition: h1conn.c:339
asprintf
int asprintf(char **, const char *,...)
vlc_http_mgr::jar
struct vlc_http_cookie_jar_t * jar
Definition: connmgr.c:99
vlc_http_conn
Definition: conn.h:39
conn.h
vlc_https_request
static struct vlc_http_msg * vlc_https_request(struct vlc_http_mgr *mgr, const char *host, unsigned port, const struct vlc_http_msg *req)
Definition: connmgr.c:145
vlc_url_t::psz_host
char * psz_host
Definition: vlc_url.h:150
vlc_tls_Delete
void vlc_tls_Delete(vlc_tls_creds_t *crd)
Releases TLS credentials.
Definition: tls.c:128
vlc_http_mgr::obj
vlc_object_t * obj
Definition: connmgr.c:97
vlc_https_connect
vlc_tls_t * vlc_https_connect(vlc_tls_creds_t *creds, const char *name, unsigned port, bool *restrict two)
Definition: connmgr.c:55
vlc_http_msg_get_initial
struct vlc_http_msg * vlc_http_msg_get_initial(struct vlc_http_stream *s)
Definition: message.c:274
message.h
vlc_http_mgr_destroy
void vlc_http_mgr_destroy(struct vlc_http_mgr *mgr)
Destroys an HTTP connection manager.
Definition: connmgr.c:280
vlc_tls_Close
static void vlc_tls_Close(vlc_tls_t *session)
Closes a connection and its underlying resources.
Definition: vlc_tls.h:257
vlc_http_stream
HTTP stream.
Definition: message.h:340
vlc_http_mgr::conn
struct vlc_http_conn * conn
Definition: connmgr.c:100
vlc_url.h
vlc_http_err
void vlc_http_err(void *ctx, const char *fmt,...)
Definition: connmgr.c:37
likely
#define likely(p)
Definition: vlc_common.h:113
vlc_url_t
Definition: vlc_url.h:145
vlc_object_t
The main vlc_object_t structure.
Definition: vlc_objects.h:39
vlc_http_mgr_get_jar
struct vlc_http_cookie_jar_t * vlc_http_mgr_get_jar(struct vlc_http_mgr *mgr)
Definition: connmgr.c:261
connmgr.h
vlc_http_conn_release
static void vlc_http_conn_release(struct vlc_http_conn *conn)
Definition: conn.h:51
vlc_url_t::i_port
unsigned i_port
Definition: vlc_url.h:151
vlc_http_conn::tls
struct vlc_tls * tls
Definition: conn.h:42
name
const char name[16]
Definition: httpd.c:1249
vlc_tls.h
unlikely
#define unlikely(p)
Definition: vlc_common.h:114
vlc_tls_ClientCreate
vlc_tls_creds_t * vlc_tls_ClientCreate(vlc_object_t *obj)
Allocates TLS credentials for a client.
Definition: tls.c:109
transport.h
vlc_http_mgr_find
static struct vlc_http_conn * vlc_http_mgr_find(struct vlc_http_mgr *mgr, const char *host, unsigned port)
Definition: connmgr.c:103
vlc_http_proxy_find
static char * vlc_http_proxy_find(const char *hostname, unsigned port, bool secure)
Definition: connmgr.c:75
VLC_MSG_DBG
Debug.
Definition: vlc_messages.h:49
vlc_http_dbg
void vlc_http_dbg(void *ctx, const char *fmt,...)
Definition: connmgr.c:46
vlc_http_msg
Definition: message.c:40
vlc_http_stream_open
static struct vlc_http_stream * vlc_http_stream_open(struct vlc_http_conn *conn, const struct vlc_http_msg *m)
Definition: conn.h:46
vlc_tls_SocketOpenTLS
vlc_tls_t * vlc_tls_SocketOpenTLS(vlc_tls_creds_t *creds, const char *name, unsigned port, const char *service, const char *const *alpn, char **alp)
Initiates a TLS session over TCP.
Definition: tls.c:626