mirror of https://code.videolan.org/videolan/vlc
Merge branch 'http-verbose' into 'master'
access: http: only use verbose logs with verbosity 4 or higher See merge request videolan/vlc!2111
This commit is contained in:
commit
350c00d0bf
|
@ -714,7 +714,8 @@ static int Connect( stream_t *p_access )
|
|||
return -1;
|
||||
}
|
||||
|
||||
msg_Dbg( p_access, "sending request:\n%s", stream.ptr );
|
||||
if (var_InheritInteger(p_access, "verbose") >= 4)
|
||||
msg_Dbg( p_access, "sending request:\n%s", stream.ptr );
|
||||
val = vlc_tls_Write(p_sys->stream, stream.ptr, stream.length);
|
||||
free( stream.ptr );
|
||||
|
||||
|
|
|
@ -56,14 +56,14 @@ static inline void vlc_http_conn_release(struct vlc_http_conn *conn)
|
|||
conn->cbs->release(conn);
|
||||
}
|
||||
|
||||
void vlc_http_err(void *, const char *msg, ...) VLC_FORMAT(2, 3);
|
||||
void vlc_http_dbg(void *, const char *msg, ...) VLC_FORMAT(2, 3);
|
||||
void vlc_http_err(struct vlc_logger *, const char *msg, ...) VLC_FORMAT(2, 3);
|
||||
void vlc_http_dbg(struct vlc_logger *, const char *msg, ...) VLC_FORMAT(2, 3);
|
||||
|
||||
/**
|
||||
* \defgroup http1 HTTP/1.x
|
||||
* @{
|
||||
*/
|
||||
struct vlc_http_conn *vlc_h1_conn_create(void *ctx, struct vlc_tls *,
|
||||
struct vlc_http_conn *vlc_h1_conn_create(struct vlc_logger *, struct vlc_tls *,
|
||||
bool proxy);
|
||||
struct vlc_http_stream *vlc_chunked_open(struct vlc_http_stream *,
|
||||
struct vlc_tls *);
|
||||
|
@ -86,7 +86,7 @@ ssize_t vlc_https_chunked_write(struct vlc_tls *, const void *base, size_t len,
|
|||
* however be sent with the TLS False Start. This is handled by the TLS stack
|
||||
* and does not require a combined function call.
|
||||
*
|
||||
* \param ctx opaque context pointer for the HTTP connection
|
||||
* \param logger logger pointer for the HTTP connection
|
||||
* \param hostname HTTP server or proxy hostname to connect to
|
||||
* \param port TCP port number to connect to
|
||||
* \param proxy true of the hostname and port correspond to an HTTP proxy,
|
||||
|
@ -101,7 +101,7 @@ ssize_t vlc_https_chunked_write(struct vlc_tls *, const void *base, size_t len,
|
|||
* \return an HTTP stream on success, NULL on error
|
||||
* \note *connp is undefined on error.
|
||||
*/
|
||||
struct vlc_http_stream *vlc_h1_request(void *ctx, const char *hostname,
|
||||
struct vlc_http_stream *vlc_h1_request(struct vlc_logger *logger, const char *hostname,
|
||||
unsigned port, bool proxy,
|
||||
const struct vlc_http_msg *req,
|
||||
bool idempotent, bool has_data,
|
||||
|
@ -113,7 +113,7 @@ struct vlc_http_stream *vlc_h1_request(void *ctx, const char *hostname,
|
|||
* \defgroup h2 HTTP/2.0
|
||||
* @{
|
||||
*/
|
||||
struct vlc_http_conn *vlc_h2_conn_create(void *ctx, struct vlc_tls *);
|
||||
struct vlc_http_conn *vlc_h2_conn_create(struct vlc_logger *, struct vlc_tls *);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -34,9 +34,11 @@
|
|||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
void vlc_http_err(void *ctx, const char *fmt, ...)
|
||||
void vlc_http_err(struct vlc_logger *logger, const char *fmt, ...)
|
||||
{
|
||||
struct vlc_logger *logger = ctx;
|
||||
if (logger == NULL)
|
||||
return;
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
@ -45,9 +47,11 @@ void vlc_http_err(void *ctx, const char *fmt, ...)
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
void vlc_http_dbg(void *ctx, const char *fmt, ...)
|
||||
void vlc_http_dbg(struct vlc_logger *logger, const char *fmt, ...)
|
||||
{
|
||||
struct vlc_logger *logger = ctx;
|
||||
if (logger == NULL)
|
||||
return;
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
@ -176,7 +180,7 @@ static struct vlc_http_msg *vlc_https_request(struct vlc_http_mgr *mgr,
|
|||
char *proxy = vlc_http_proxy_find(host, port, true);
|
||||
if (proxy != NULL)
|
||||
{
|
||||
tls = vlc_https_connect_proxy(mgr->creds, mgr->creds,
|
||||
tls = vlc_https_connect_proxy(mgr->logger, mgr->creds,
|
||||
host, port, &http2, proxy);
|
||||
free(proxy);
|
||||
}
|
||||
|
@ -294,7 +298,10 @@ struct vlc_http_mgr *vlc_http_mgr_create(vlc_object_t *obj,
|
|||
if (unlikely(mgr == NULL))
|
||||
return NULL;
|
||||
|
||||
mgr->logger = obj->logger;
|
||||
if (var_InheritInteger(obj, "verbose") >= 4)
|
||||
mgr->logger = obj->logger;
|
||||
else
|
||||
mgr->logger = NULL;
|
||||
mgr->obj = obj;
|
||||
mgr->creds = NULL;
|
||||
mgr->jar = jar;
|
||||
|
|
|
@ -116,10 +116,10 @@ struct vlc_h1_conn
|
|||
bool active;
|
||||
bool released;
|
||||
bool proxy;
|
||||
void *opaque;
|
||||
struct vlc_logger *logger;
|
||||
};
|
||||
|
||||
#define CO(conn) ((conn)->opaque)
|
||||
#define CO(conn) ((conn)->logger)
|
||||
|
||||
static void vlc_h1_conn_destroy(struct vlc_h1_conn *conn);
|
||||
|
||||
|
@ -346,7 +346,7 @@ static const struct vlc_http_conn_cbs vlc_h1_conn_callbacks =
|
|||
vlc_h1_conn_release,
|
||||
};
|
||||
|
||||
struct vlc_http_conn *vlc_h1_conn_create(void *ctx, vlc_tls_t *tls, bool proxy)
|
||||
struct vlc_http_conn *vlc_h1_conn_create(struct vlc_logger *logger, vlc_tls_t *tls, bool proxy)
|
||||
{
|
||||
struct vlc_h1_conn *conn = malloc(sizeof (*conn));
|
||||
if (unlikely(conn == NULL))
|
||||
|
@ -358,12 +358,12 @@ struct vlc_http_conn *vlc_h1_conn_create(void *ctx, vlc_tls_t *tls, bool proxy)
|
|||
conn->active = false;
|
||||
conn->released = false;
|
||||
conn->proxy = proxy;
|
||||
conn->opaque = ctx;
|
||||
conn->logger = logger;
|
||||
|
||||
return &conn->conn;
|
||||
}
|
||||
|
||||
struct vlc_http_stream *vlc_h1_request(void *ctx, const char *hostname,
|
||||
struct vlc_http_stream *vlc_h1_request(struct vlc_logger *logger, const char *hostname,
|
||||
unsigned port, bool proxy,
|
||||
const struct vlc_http_msg *req,
|
||||
bool idempotent, bool has_data,
|
||||
|
@ -375,12 +375,12 @@ struct vlc_http_stream *vlc_h1_request(void *ctx, const char *hostname,
|
|||
.ai_protocol = IPPROTO_TCP,
|
||||
}, *res;
|
||||
|
||||
vlc_http_dbg(ctx, "resolving %s ...", hostname);
|
||||
vlc_http_dbg(logger, "resolving %s ...", hostname);
|
||||
|
||||
int val = vlc_getaddrinfo_i11e(hostname, port, &hints, &res);
|
||||
if (val != 0)
|
||||
{ /* TODO: C locale for gai_strerror() */
|
||||
vlc_http_err(ctx, "cannot resolve %s: %s", hostname,
|
||||
vlc_http_err(logger, "cannot resolve %s: %s", hostname,
|
||||
gai_strerror(val));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -390,11 +390,11 @@ struct vlc_http_stream *vlc_h1_request(void *ctx, const char *hostname,
|
|||
vlc_tls_t *tcp = vlc_tls_SocketOpenAddrInfo(p, idempotent);
|
||||
if (tcp == NULL)
|
||||
{
|
||||
vlc_http_err(ctx, "socket error: %s", vlc_strerror_c(errno));
|
||||
vlc_http_err(logger, "socket error: %s", vlc_strerror_c(errno));
|
||||
continue;
|
||||
}
|
||||
|
||||
struct vlc_http_conn *conn = vlc_h1_conn_create(ctx, tcp, proxy);
|
||||
struct vlc_http_conn *conn = vlc_h1_conn_create(logger, tcp, proxy);
|
||||
if (unlikely(conn == NULL))
|
||||
{
|
||||
vlc_tls_SessionDelete(tcp);
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "conn.h"
|
||||
#include "message.h"
|
||||
|
||||
#define CO(c) ((c)->opaque)
|
||||
#define CO(c) ((c)->logger)
|
||||
#define SO(s) CO((s)->conn)
|
||||
|
||||
/** HTTP/2 connection */
|
||||
|
@ -52,7 +52,7 @@ struct vlc_h2_conn
|
|||
{
|
||||
struct vlc_http_conn conn;
|
||||
struct vlc_h2_output *out; /**< Send thread */
|
||||
void *opaque;
|
||||
struct vlc_logger *logger;
|
||||
|
||||
struct vlc_h2_stream *streams; /**< List of open streams */
|
||||
uint32_t next_id; /**< Next free stream identifier */
|
||||
|
@ -94,14 +94,14 @@ struct vlc_h2_stream
|
|||
|
||||
static int vlc_h2_conn_queue(struct vlc_h2_conn *conn, struct vlc_h2_frame *f)
|
||||
{
|
||||
vlc_h2_frame_dump(conn->opaque, f, "out");
|
||||
vlc_h2_frame_dump(conn->logger, f, "out");
|
||||
return vlc_h2_output_send(conn->out, f);
|
||||
}
|
||||
|
||||
static int vlc_h2_conn_queue_prio(struct vlc_h2_conn *conn,
|
||||
struct vlc_h2_frame *f)
|
||||
{
|
||||
vlc_h2_frame_dump(conn->opaque, f, "out (priority)");
|
||||
vlc_h2_frame_dump(conn->logger, f, "out (priority)");
|
||||
return vlc_h2_output_send_prio(conn->out, f);
|
||||
}
|
||||
|
||||
|
@ -871,7 +871,7 @@ static const struct vlc_http_conn_cbs vlc_h2_conn_callbacks =
|
|||
vlc_h2_conn_release,
|
||||
};
|
||||
|
||||
struct vlc_http_conn *vlc_h2_conn_create(void *ctx, struct vlc_tls *tls)
|
||||
struct vlc_http_conn *vlc_h2_conn_create(struct vlc_logger *logger, struct vlc_tls *tls)
|
||||
{
|
||||
struct vlc_h2_conn *conn = malloc(sizeof (*conn));
|
||||
if (unlikely(conn == NULL))
|
||||
|
@ -880,7 +880,7 @@ struct vlc_http_conn *vlc_h2_conn_create(void *ctx, struct vlc_tls *tls)
|
|||
conn->conn.cbs = &vlc_h2_conn_callbacks;
|
||||
conn->conn.tls = tls;
|
||||
conn->out = vlc_h2_output_create(tls, true);
|
||||
conn->opaque = ctx;
|
||||
conn->logger = logger;
|
||||
conn->streams = NULL;
|
||||
conn->next_id = 1; /* TODO: server side */
|
||||
conn->released = false;
|
||||
|
|
|
@ -402,7 +402,7 @@ const char *vlc_h2_strerror(uint_fast32_t code)
|
|||
return names[code];
|
||||
}
|
||||
|
||||
void vlc_h2_frame_dump(void *opaque, const struct vlc_h2_frame *f,
|
||||
void vlc_h2_frame_dump(struct vlc_logger *logger, const struct vlc_h2_frame *f,
|
||||
const char *msg)
|
||||
{
|
||||
size_t len = vlc_h2_frame_length(f);
|
||||
|
@ -411,11 +411,11 @@ void vlc_h2_frame_dump(void *opaque, const struct vlc_h2_frame *f,
|
|||
uint_fast32_t sid = vlc_h2_frame_id(f);
|
||||
|
||||
if (sid != 0)
|
||||
vlc_http_dbg(opaque, "%s %s (0x%02"PRIxFAST8") frame of %zu bytes, "
|
||||
vlc_http_dbg(logger, "%s %s (0x%02"PRIxFAST8") frame of %zu bytes, "
|
||||
"flags 0x%02"PRIxFAST8", stream %"PRIuFAST32, msg,
|
||||
vlc_h2_type_name(type), type, len, flags, sid);
|
||||
else
|
||||
vlc_http_dbg(opaque, "%s %s (0x%02"PRIxFAST8") frame of %zu bytes, "
|
||||
vlc_http_dbg(logger, "%s %s (0x%02"PRIxFAST8") frame of %zu bytes, "
|
||||
"flags 0x%02"PRIxFAST8", global", msg,
|
||||
vlc_h2_type_name(type), type, len, flags);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ vlc_h2_frame_goaway(uint_fast32_t last_stream_id, uint_fast32_t error_code);
|
|||
struct vlc_h2_frame *
|
||||
vlc_h2_frame_window_update(uint_fast32_t stream_id, uint_fast32_t credit);
|
||||
|
||||
void vlc_h2_frame_dump(void *, const struct vlc_h2_frame *, const char *);
|
||||
void vlc_h2_frame_dump(struct vlc_logger *, const struct vlc_h2_frame *, const char *);
|
||||
|
||||
enum vlc_h2_error {
|
||||
VLC_H2_NO_ERROR,
|
||||
|
|
|
@ -41,12 +41,13 @@ static char *const CTX = &dummy;
|
|||
static unsigned settings;
|
||||
|
||||
/* Callbacks */
|
||||
void vlc_http_dbg(void *stream, const char *fmt, ...)
|
||||
void vlc_http_dbg(struct vlc_logger *logger, const char *fmt, ...)
|
||||
{
|
||||
(void) logger;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stream, fmt, ap);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include "transport.h"
|
||||
#include <vlc_common.h>
|
||||
#include "transport.h"
|
||||
|
||||
/* Must be in ascending order */
|
||||
static const unsigned short blocked_ports[] = {
|
||||
|
|
|
@ -30,7 +30,7 @@ struct vlc_tls_client;
|
|||
struct vlc_tls *vlc_https_connect(struct vlc_tls_client *creds,
|
||||
const char *name, unsigned port,
|
||||
bool *restrict two);
|
||||
struct vlc_tls *vlc_https_connect_proxy(void *ctx,
|
||||
struct vlc_tls *vlc_https_connect_proxy(struct vlc_logger *,
|
||||
struct vlc_tls_client *creds,
|
||||
const char *name, unsigned port,
|
||||
bool *restrict two, const char *proxy);
|
||||
|
|
|
@ -132,7 +132,7 @@ static const struct vlc_tls_operations vlc_tls_proxy_ops =
|
|||
vlc_tls_ProxyClose,
|
||||
};
|
||||
|
||||
vlc_tls_t *vlc_https_connect_proxy(void *ctx, vlc_tls_client_t *creds,
|
||||
vlc_tls_t *vlc_https_connect_proxy(struct vlc_logger *logger, vlc_tls_client_t *creds,
|
||||
const char *hostname, unsigned port,
|
||||
bool *restrict two, const char *proxy)
|
||||
{
|
||||
|
@ -184,8 +184,8 @@ vlc_tls_t *vlc_https_connect_proxy(void *ctx, vlc_tls_client_t *creds,
|
|||
psock->tls.p = NULL;
|
||||
psock->sock = sock;
|
||||
|
||||
struct vlc_http_conn *conn = /*ptwo ? vlc_h2_conn_create(ctx, &psock->tls)
|
||||
:*/ vlc_h1_conn_create(ctx, &psock->tls, false);
|
||||
struct vlc_http_conn *conn = /*ptwo ? vlc_h2_conn_create(logger, &psock->tls)
|
||||
:*/ vlc_h1_conn_create(logger, &psock->tls, false);
|
||||
if (unlikely(conn == NULL))
|
||||
{
|
||||
vlc_tls_Close(&psock->tls);
|
||||
|
|
Loading…
Reference in New Issue