Commit aed69fef authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

* modules/control/http.c : specify UTF-8 as charset (closes #236)

 * share/html/* : sepcify UTF-8 as XML encoding
 * httpd.c : add a bunch of "const"
parent 0b99d8cc
......@@ -121,8 +121,8 @@ VLC_EXPORT( httpd_host_t *, httpd_TLSHostNew, ( vlc_object_t *, const char *, in
VLC_EXPORT( void, httpd_HostDelete, ( httpd_host_t * ) );
/* register a new url */
VLC_EXPORT( httpd_url_t *, httpd_UrlNew, ( httpd_host_t *, char *psz_url, char *psz_user, char *psz_password, const vlc_acl_t *p_acl ) );
VLC_EXPORT( httpd_url_t *, httpd_UrlNewUnique, ( httpd_host_t *, char *psz_url, char *psz_user, char *psz_password, const vlc_acl_t *p_acl ) );
VLC_EXPORT( httpd_url_t *, httpd_UrlNew, ( httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl ) );
VLC_EXPORT( httpd_url_t *, httpd_UrlNewUnique, ( httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl ) );
/* register callback on a url */
VLC_EXPORT( int, httpd_UrlCatch, ( httpd_url_t *, int i_msg, httpd_callback_t, httpd_callback_sys_t * ) );
/* delete an url */
......@@ -136,15 +136,15 @@ VLC_EXPORT( char*, httpd_ServerIP, ( httpd_client_t *cl, char *psz_ip )
/* High level */
VLC_EXPORT( httpd_file_t *, httpd_FileNew, ( httpd_host_t *, char *psz_url, char *psz_mime, char *psz_user, char *psz_password, const vlc_acl_t *p_acl, httpd_file_callback_t pf_fill, httpd_file_sys_t * ) );
VLC_EXPORT( httpd_file_t *, httpd_FileNew, ( httpd_host_t *, const char *psz_url, const char *psz_mime, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl, httpd_file_callback_t pf_fill, httpd_file_sys_t * ) );
VLC_EXPORT( void, httpd_FileDelete, ( httpd_file_t * ) );
VLC_EXPORT( httpd_redirect_t *, httpd_RedirectNew, ( httpd_host_t *, char *psz_url_dst, char *psz_url_src ) );
VLC_EXPORT( httpd_redirect_t *, httpd_RedirectNew, ( httpd_host_t *, const char *psz_url_dst, const char *psz_url_src ) );
VLC_EXPORT( void, httpd_RedirectDelete, ( httpd_redirect_t * ) );
VLC_EXPORT( httpd_stream_t *, httpd_StreamNew, ( httpd_host_t *, char *psz_url, char *psz_mime, char *psz_user, char *psz_password, const vlc_acl_t *p_acl ) );
VLC_EXPORT( httpd_stream_t *, httpd_StreamNew, ( httpd_host_t *, const char *psz_url, const char *psz_mime, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl ) );
VLC_EXPORT( void, httpd_StreamDelete, ( httpd_stream_t * ) );
VLC_EXPORT( int, httpd_StreamHeader, ( httpd_stream_t *, uint8_t *p_data, int i_data ) );
VLC_EXPORT( int, httpd_StreamSend, ( httpd_stream_t *, uint8_t *p_data, int i_data ) );
......
......@@ -195,18 +195,18 @@ struct module_symbols_t
httpd_host_t * (*httpd_HostNew_inner) (vlc_object_t *, const char *psz_host, int i_port);
httpd_host_t * (*httpd_TLSHostNew_inner) (vlc_object_t *, const char *, int, const char *, const char *, const char *, const char *);
void (*httpd_HostDelete_inner) (httpd_host_t *);
httpd_url_t * (*httpd_UrlNew_inner) (httpd_host_t *, char *psz_url, char *psz_user, char *psz_password, const vlc_acl_t *p_acl);
httpd_url_t * (*httpd_UrlNewUnique_inner) (httpd_host_t *, char *psz_url, char *psz_user, char *psz_password, const vlc_acl_t *p_acl);
httpd_url_t * (*httpd_UrlNew_inner) (httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl);
httpd_url_t * (*httpd_UrlNewUnique_inner) (httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl);
int (*httpd_UrlCatch_inner) (httpd_url_t *, int i_msg, httpd_callback_t, httpd_callback_sys_t *);
void (*httpd_UrlDelete_inner) (httpd_url_t *);
void (*httpd_ClientModeStream_inner) (httpd_client_t *cl);
void (*httpd_ClientModeBidir_inner) (httpd_client_t *cl);
char* (*httpd_ClientIP_inner) (httpd_client_t *cl, char *psz_ip);
httpd_file_t * (*httpd_FileNew_inner) (httpd_host_t *, char *psz_url, char *psz_mime, char *psz_user, char *psz_password, const vlc_acl_t *p_acl, httpd_file_callback_t pf_fill, httpd_file_sys_t *);
httpd_file_t * (*httpd_FileNew_inner) (httpd_host_t *, const char *psz_url, const char *psz_mime, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl, httpd_file_callback_t pf_fill, httpd_file_sys_t *);
void (*httpd_FileDelete_inner) (httpd_file_t *);
httpd_redirect_t * (*httpd_RedirectNew_inner) (httpd_host_t *, char *psz_url_dst, char *psz_url_src);
httpd_redirect_t * (*httpd_RedirectNew_inner) (httpd_host_t *, const char *psz_url_dst, const char *psz_url_src);
void (*httpd_RedirectDelete_inner) (httpd_redirect_t *);
httpd_stream_t * (*httpd_StreamNew_inner) (httpd_host_t *, char *psz_url, char *psz_mime, char *psz_user, char *psz_password, const vlc_acl_t *p_acl);
httpd_stream_t * (*httpd_StreamNew_inner) (httpd_host_t *, const char *psz_url, const char *psz_mime, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl);
void (*httpd_StreamDelete_inner) (httpd_stream_t *);
int (*httpd_StreamHeader_inner) (httpd_stream_t *, uint8_t *p_data, int i_data);
int (*httpd_StreamSend_inner) (httpd_stream_t *, uint8_t *p_data, int i_data);
......
......@@ -42,7 +42,6 @@
#include "vlc_vlm.h"
#include "vlc_tls.h"
#include "vlc_acl.h"
#include "charset.h"
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
......@@ -198,7 +197,6 @@ struct intf_sys_t
playlist_t *p_playlist;
input_thread_t *p_input;
vlm_t *p_vlm;
char *psz_html_type;
};
......@@ -240,23 +238,6 @@ static int Open( vlc_object_t *p_this )
p_sys->p_input = NULL;
p_sys->p_vlm = NULL;
/* determine Content-Type value for HTML pages */
vlc_current_charset(&psz_src);
if( psz_src == NULL )
{
free( p_sys );
return VLC_ENOMEM;
}
p_sys->psz_html_type = malloc( 20 + strlen( psz_src ) );
if( p_sys->psz_html_type == NULL )
{
free( p_sys );
free( psz_src );
return VLC_ENOMEM ;
}
sprintf( p_sys->psz_html_type, "text/html; charset=%s", psz_src );
free( psz_src );
/* determine SSL configuration */
psz_cert = config_GetPsz( p_intf, "http-intf-cert" );
if ( psz_cert != NULL )
......@@ -284,7 +265,6 @@ static int Open( vlc_object_t *p_this )
if( p_sys->p_httpd_host == NULL )
{
msg_Err( p_intf, "cannot listen on %s:%d", psz_address, i_port );
free( p_sys->psz_html_type );
free( p_sys );
return VLC_EGENERIC;
}
......@@ -358,7 +338,6 @@ failed:
free( p_sys->pp_files );
}
httpd_HostDelete( p_sys->p_httpd_host );
free( p_sys->psz_html_type );
free( p_sys );
return VLC_EGENERIC;
}
......@@ -395,7 +374,6 @@ void Close ( vlc_object_t *p_this )
}
httpd_HostDelete( p_sys->p_httpd_host );
free( p_sys->psz_html_type );
free( p_sys );
}
......@@ -513,6 +491,7 @@ static char *FileToUrl( char *name, vlc_bool_t *pb_index )
static int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
char *psz_dir )
{
static const char mimetype[] = "text/html; charset=UTF-8";
intf_sys_t *p_sys = p_intf->p_sys;
char dir[MAX_DIR_SIZE];
#ifdef HAVE_SYS_STAT_H
......@@ -630,7 +609,7 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
f->p_file = httpd_FileNew( p_sys->p_httpd_host,
f->name,
f->b_html ? p_sys->psz_html_type : NULL,
f->b_html ? mimetype : NULL,
user, password, p_acl,
HttpCallback, f );
......
<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!-- $Id$-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml10/DTD/xhtml10transitional.dtd">
......@@ -8,7 +8,6 @@
<head>
<title>VLC media player</title>
<link href="/style.css" title="Default" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- Work around. should be done in the code -->
<vlc id="if" param1="url_param"/>
<meta http-equiv="Refresh" content="0;url=/" />
......
<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml10/DTD/xhtml10transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
......
<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml10/DTD/xhtml10transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
......
<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml10/DTD/xhtml10transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
......
<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml10/DTD/xhtml10transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
......
......@@ -364,8 +364,8 @@ static void b64_decode( char *dest, char *src )
static struct
{
char *psz_ext;
char *psz_mime;
const char *psz_ext;
const char *psz_mime;
} http_mime[] =
{
{ ".htm", "text/html" },
......@@ -409,7 +409,7 @@ static struct
/* end */
{ NULL, NULL }
};
static char *httpd_MimeFromUrl( char *psz_url )
static const char *httpd_MimeFromUrl( const char *psz_url )
{
char *psz_ext;
......@@ -489,8 +489,8 @@ static int httpd_FileCallBack( httpd_callback_sys_t *p_sys, httpd_client_t *cl,
httpd_file_t *httpd_FileNew( httpd_host_t *host,
char *psz_url, char *psz_mime,
char *psz_user, char *psz_password,
const char *psz_url, const char *psz_mime,
const char *psz_user, const char *psz_password,
const vlc_acl_t *p_acl, httpd_file_callback_t pf_fill,
httpd_file_sys_t *p_sys )
{
......@@ -573,7 +573,7 @@ static int httpd_RedirectCallBack( httpd_callback_sys_t *p_sys,
"<title>Redirection</title>\n"
"</head>\n"
"<body>\n"
"<h1>You should be "
"<h1>You should be "
"<a href=\"%s\">redirected</a></h1>\n"
"<hr />\n"
"<p><a href=\"http://www.videolan.org\">VideoLAN</a>\n</p>"
......@@ -590,8 +590,8 @@ static int httpd_RedirectCallBack( httpd_callback_sys_t *p_sys,
return VLC_SUCCESS;
}
httpd_redirect_t *httpd_RedirectNew( httpd_host_t *host, char *psz_url_dst,
char *psz_url_src )
httpd_redirect_t *httpd_RedirectNew( httpd_host_t *host, const char *psz_url_dst,
const char *psz_url_src )
{
httpd_redirect_t *rdir = malloc( sizeof( httpd_redirect_t ) );
......@@ -769,8 +769,8 @@ static int httpd_StreamCallBack( httpd_callback_sys_t *p_sys,
}
httpd_stream_t *httpd_StreamNew( httpd_host_t *host,
char *psz_url, char *psz_mime,
char *psz_user, char *psz_password,
const char *psz_url, const char *psz_mime,
const char *psz_user, const char *psz_password,
const vlc_acl_t *p_acl )
{
httpd_stream_t *stream = malloc( sizeof( httpd_stream_t ) );
......@@ -1102,8 +1102,8 @@ void httpd_HostDelete( httpd_host_t *host )
}
/* register a new url */
static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *host, char *psz_url,
char *psz_user, char *psz_password,
static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *host, const char *psz_url,
const char *psz_user, const char *psz_password,
const vlc_acl_t *p_acl, vlc_bool_t b_check )
{
httpd_url_t *url;
......@@ -1144,16 +1144,16 @@ static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *host, char *psz_url,
return url;
}
httpd_url_t *httpd_UrlNew( httpd_host_t *host, char *psz_url,
char *psz_user, char *psz_password,
httpd_url_t *httpd_UrlNew( httpd_host_t *host, const char *psz_url,
const char *psz_user, const char *psz_password,
const vlc_acl_t *p_acl )
{
return httpd_UrlNewPrivate( host, psz_url, psz_user,
psz_password, p_acl, VLC_FALSE );
}
httpd_url_t *httpd_UrlNewUnique( httpd_host_t *host, char *psz_url,
char *psz_user, char *psz_password,
httpd_url_t *httpd_UrlNewUnique( httpd_host_t *host, const char *psz_url,
const char *psz_user, const char *psz_password,
const vlc_acl_t *p_acl )
{
return httpd_UrlNewPrivate( host, psz_url, psz_user,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment