VLC  4.0.0-dev
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  * \ingroup net
24  * Hyper-Text Transfer Protocol
25  * \defgroup http_connmgr Connection manager
26  * HTTP connection management
27  * \ingroup http
28  * @{
29  * \file connmgr.h
30  */
31 
32 struct vlc_http_mgr;
33 struct vlc_http_msg;
35 
36 /**
37  * Sends an HTTP request
38  *
39  * Sends an HTTP request, by either reusing an existing HTTP connection or
40  * establishing a new one. If succesful, the initial HTTP response header is
41  * returned.
42  *
43  * @param mgr HTTP connection manager
44  * @param https whether to use HTTPS (true) or unencrypted HTTP (false)
45  * @param host name of authoritative HTTP server to send the request to
46  * @param port TCP server port number, or 0 for the default port number
47  * @param req HTTP request header to send
48  * @param idempotent whether the request is idempotent
49  * @param payload whether the request will carry a payload
50  *
51  * @return The initial HTTP response header, or NULL in case of failure.
52  */
53 struct vlc_http_msg *vlc_http_mgr_request(struct vlc_http_mgr *mgr, bool https,
54  const char *host, unsigned port,
55  const struct vlc_http_msg *req,
56  bool idempotent, bool payload);
57 
59 
60 /**
61  * Creates an HTTP connection manager
62  *
63  * Allocates an HTTP client connections manager.
64  *
65  * @param obj parent VLC object
66  * @param jar HTTP cookies jar (NULL to disable cookies)
67  */
69  struct vlc_http_cookie_jar_t *jar);
70 
71 /**
72  * Destroys an HTTP connection manager
73  *
74  * Deallocates an HTTP client connections manager created by
75  * vlc_http_msg_destroy(). Any remaining connection is closed and destroyed.
76  */
77 void vlc_http_mgr_destroy(struct vlc_http_mgr *mgr);
78 
79 /** @} */
vlc_h2_conn_create
struct vlc_http_conn * vlc_h2_conn_create(void *ctx, struct vlc_tls *)
Definition: h2conn.c:877
vlc_tls_ClientCreate
vlc_tls_client_t * vlc_tls_ClientCreate(vlc_object_t *obj)
Allocates TLS client-side credentials.
Definition: tls.c:93
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, bool has_data, struct vlc_http_conn **restrict connp)
Sends an HTTP/1.x request through a new connection.
Definition: h1conn.c:357
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, bool payload)
Definition: connmgr.c:125
unlikely
#define unlikely(p)
Predicted false condition.
Definition: vlc_common.h:227
vlc_common.h
vlc_logger
Definition: messages.c:54
vlc_object_t::logger
struct vlc_logger * logger
Definition: vlc_objects.h:45
vlc_network.h
vlc_http_mgr
Definition: connmgr.c:99
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:290
vlc_h1_conn_create
struct vlc_http_conn * vlc_h1_conn_create(void *ctx, struct vlc_tls *, bool proxy)
Definition: h1conn.c:340
vlc_https_connect
vlc_tls_t * vlc_https_connect(vlc_tls_client_t *creds, const char *name, unsigned port, bool *restrict two)
Definition: connmgr.c:59
vlc_tls
Transport layer socket.
Definition: vlc_tls.h:65
vlc_http_mgr_release
static void vlc_http_mgr_release(struct vlc_http_mgr *mgr, struct vlc_http_conn *conn)
Definition: connmgr.c:115
vlc_UrlClean
void vlc_UrlClean(vlc_url_t *restrict url)
Definition: url.c:598
vlc_getProxyUrl
char * vlc_getProxyUrl(const char *url)
Determines the network proxy server to use (if any).
Definition: specific.c:342
vlc_http_port_blocked
bool vlc_http_port_blocked(unsigned port)
Definition: ports.c:106
vlc_tls_SocketOpenTLS
vlc_tls_t * vlc_tls_SocketOpenTLS(vlc_tls_client_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:217
vlc_http_stream_open
static struct vlc_http_stream * vlc_http_stream_open(struct vlc_http_conn *conn, const struct vlc_http_msg *m, bool has_data)
Definition: conn.h:48
VLC_MSG_ERR
@ VLC_MSG_ERR
Error.
Definition: vlc_messages.h:48
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, bool idempotent, bool payload)
Definition: connmgr.c:146
asprintf
int asprintf(char **, const char *,...)
vlc_http_mgr::jar
struct vlc_http_cookie_jar_t * jar
Definition: connmgr.c:104
vlc_http_conn
Definition: conn.h:41
conn.h
vlc_http_msg::payload
struct vlc_http_stream * payload
Definition: message.c:69
vlc_tls_ClientDelete
void vlc_tls_ClientDelete(vlc_tls_client_t *crd)
Releases TLS client-side credentials.
Definition: tls.c:122
vlc_url_t::psz_host
char * psz_host
Definition: vlc_url.h:150
vlc_http_mgr::obj
vlc_object_t * obj
Definition: connmgr.c:102
vlc_http_msg_get_initial
struct vlc_http_msg * vlc_http_msg_get_initial(struct vlc_http_stream *s)
Definition: message.c:276
vlc_UrlParse
int vlc_UrlParse(vlc_url_t *url, const char *str)
Parses an URI or IRI.
Definition: url.c:558
message.h
vlc_vaLog
void vlc_vaLog(struct vlc_logger *const *loggerp, int type, const char *typename, const char *module, const char *file, unsigned line, const char *func, const char *format, va_list args)
Definition: messages.c:85
vlc_http_mgr_destroy
void vlc_http_mgr_destroy(struct vlc_http_mgr *mgr)
Destroys an HTTP connection manager.
Definition: connmgr.c:305
vlc_tls_Close
static void vlc_tls_Close(vlc_tls_t *session)
Closes a connection and its underlying resources.
Definition: vlc_tls.h:397
vlc_http_stream
HTTP stream.
Definition: message.h:366
vlc_http_mgr::conn
struct vlc_http_conn * conn
Definition: connmgr.c:105
vlc_url.h
vlc_http_err
void vlc_http_err(void *ctx, const char *fmt,...)
Definition: connmgr.c:37
vlc_url_t
Definition: vlc_url.h:145
vlc_object_t
VLC object common members.
Definition: vlc_objects.h:43
vlc_http_mgr_get_jar
struct vlc_http_cookie_jar_t * vlc_http_mgr_get_jar(struct vlc_http_mgr *mgr)
Definition: connmgr.c:285
vlc_http_mgr::logger
struct vlc_logger * logger
Definition: connmgr.c:101
connmgr.h
vlc_http_conn_release
static void vlc_http_conn_release(struct vlc_http_conn *conn)
Definition: conn.h:54
vlc_url_t::i_port
unsigned i_port
Definition: vlc_url.h:151
vlc_http_conn::tls
struct vlc_tls * tls
Definition: conn.h:44
name
const char name[16]
Definition: httpd.c:1268
vlc_http_mgr::creds
vlc_tls_client_t * creds
Definition: connmgr.c:103
vlc_tls.h
vlc_tls_client
TLS client-side credentials.
Definition: vlc_tls.h:140
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:108
vlc_http_proxy_find
static char * vlc_http_proxy_find(const char *hostname, unsigned port, bool secure)
Definition: connmgr.c:79
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, bool idempotent, bool payload)
Definition: connmgr.c:216
likely
#define likely(p)
Predicted true condition.
Definition: vlc_common.h:218
VLC_MSG_DBG
@ VLC_MSG_DBG
Debug.
Definition: vlc_messages.h:50
vlc_https_connect_proxy
struct vlc_tls * vlc_https_connect_proxy(void *ctx, struct vlc_tls_client *creds, const char *name, unsigned port, bool *restrict two, const char *proxy)
Definition: tunnel.c:134
vlc_http_dbg
void vlc_http_dbg(void *ctx, const char *fmt,...)
Definition: connmgr.c:48
vlc_http_msg
Definition: message.c:42
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, bool idempotent, bool payload)
Sends an HTTP request.
Definition: connmgr.c:273