static int config_newcfg = 0;
void
-config_boot ( const char *path, gid_t gid, uid_t uid )
+config_boot
+ ( const char *path, gid_t gid, uid_t uid, const char *http_user_agent )
{
struct stat st;
char buf[1024];
config.realm = strdup("tvheadend");
if (tvh_str_default(config.http_server_name, NULL) == NULL)
config.http_server_name = strdup("HTS/tvheadend");
+ if ((config.http_user_agent &&
+ strncmp(config.http_user_agent, "TVHeadend/", 10) == 0) ||
+ tvh_str_default(config.http_user_agent, NULL) == NULL) {
+ snprintf(buf, sizeof(buf), "TVHeadend/%s", tvheadend_version);
+ tvh_str_set(&config.http_user_agent, buf);
+ }
if (!config_scanfile_ok)
config_muxconfpath_notify(&config.idnode, NULL);
}
free(config.wizard);
free(config.full_version);
free(config.http_server_name);
+ free(config.http_user_agent);
free(config.server_name);
free(config.language);
free(config.language_ui);
.opts = PO_EXPERT,
.group = 5
},
+ {
+ .type = PT_STR,
+ .id = "http_user_agent",
+ .name = N_("HTTP User Agent"),
+ .desc = N_("The user agent string for the build-in HTTP client."),
+ .off = offsetof(config_t, http_user_agent),
+ .opts = PO_HIDDEN | PO_EXPERT,
+ .group = 6,
+ },
{
.type = PT_INT,
.id = "iptv_tpool",
char *full_version;
char *server_name;
char *http_server_name;
+ char *http_user_agent;
char *language;
char *info_area;
int chname_num;
extern const idclass_t config_class;
extern config_t config;
-void config_boot ( const char *path, gid_t gid, uid_t uid );
-void config_init ( int backup );
-void config_done ( void );
+void config_boot
+ ( const char *path, gid_t gid, uid_t uid, const char *http_user_agent );
+void config_init( int backup );
+void config_done( void );
const char *config_get_server_name ( void );
const char *config_get_http_server_name ( void );
void (*hc_conn_closed) (http_client_t *hc, int err);
};
-void http_client_init ( const char *user_agent );
+void http_client_init ( void );
void http_client_done ( void );
http_client_t*
#include "tvheadend.h"
#include "http.h"
#include "tcp.h"
+#include "config.h"
#include <pthread.h>
#include <unistd.h>
#include <sys/socket.h>
#endif
+#define HTTPCLIENT_TESTSUITE 1
+
struct http_client_ssl {
int connected;
int shutdown;
static pthread_mutex_t http_lock;
static tvh_cond_t http_cond;
static th_pipe_t http_pipe;
-static char *http_user_agent;
/*
*
http_port(hc, url->scheme, url->port));
http_arg_set(h, "Host", buf);
}
- if (http_user_agent) {
- http_arg_set(h, "User-Agent", http_user_agent);
- } else {
- snprintf(buf, sizeof(buf), "TVHeadend/%s", tvheadend_version);
- http_arg_set(h, "User-Agent", buf);
- }
+ assert(config.http_user_agent);
+ http_arg_set(h, "User-Agent", config.http_user_agent);
if (!keepalive)
http_arg_set(h, "Connection", "close");
http_client_basic_auth(hc, h, url->user, url->pass);
pthread_t http_client_tid;
void
-http_client_init ( const char *user_agent )
+http_client_init ( void )
{
- http_user_agent = user_agent ? strdup(user_agent) : NULL;
-
/* Setup list */
pthread_mutex_init(&http_lock, NULL);
tvh_cond_init(&http_cond);
tvhpoll_destroy(http_poll);
http_poll = NULL;
pthread_mutex_unlock(&http_lock);
- free(http_user_agent);
}
/*
uuid_init();
idnode_boot();
- config_boot(opt_config, gid, uid);
+ config_boot(opt_config, gid, uid, opt_user_agent);
tcp_server_preinit(opt_ipv6);
http_server_init(opt_bindaddr); // bind to ports only
htsp_init(opt_bindaddr); // bind to ports only
tvhftrace(LS_MAIN, codec_init);
tvhftrace(LS_MAIN, profile_init);
tvhftrace(LS_MAIN, imagecache_init);
- tvhftrace(LS_MAIN, http_client_init, opt_user_agent);
+ tvhftrace(LS_MAIN, http_client_init);
tvhftrace(LS_MAIN, esfilter_init);
tvhftrace(LS_MAIN, bouquet_init);
tvhftrace(LS_MAIN, service_init);