[vlc-devel] [PATCH 2/3] access: http: add special non media httpz protocol to force compression
Francois Cartegnie
fcvlcdev at free.fr
Wed Apr 24 22:20:08 CEST 2013
---
modules/access/http.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/modules/access/http.c b/modules/access/http.c
index 5fbd461..895935b 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -119,7 +119,7 @@ vlc_module_begin ()
add_bool( "http-forward-cookies", true, FORWARD_COOKIES_TEXT,
FORWARD_COOKIES_LONGTEXT, true )
/* 'itpc' = iTunes Podcast */
- add_shortcut( "http", "https", "unsv", "itpc", "icyx" )
+ add_shortcut( "http", "https", "unsv", "itpc", "icyx", "httpz" )
set_callbacks( Open, Close )
vlc_module_end ()
@@ -159,6 +159,7 @@ struct access_sys_t
bool b_icecast;
#ifdef HAVE_ZLIB_H
bool b_compressed;
+ bool b_shouldcompress;
struct
{
z_stream stream;
@@ -270,6 +271,7 @@ static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
if( zlibCompileFlags() & (1<<17) )
msg_Warn( p_access, "Your zlib was compiled without gzip support." );
p_sys->inflate.p_buffer = NULL;
+ p_sys->b_shouldcompress = ( strcmp( psz_access, "httpz" ) == 0 );
#endif
p_sys->p_tls = NULL;
p_sys->p_vs = NULL;
@@ -964,6 +966,9 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_CAN_SEEK:
pb_bool = (bool*)va_arg( args, bool* );
*pb_bool = p_sys->b_seekable;
+#ifdef HAVE_ZLIB_H
+ *pb_bool &= !p_sys->b_compressed;
+#endif
break;
case ACCESS_CAN_FASTSEEK:
pb_bool = (bool*)va_arg( args, bool* );
@@ -1182,6 +1187,12 @@ static int Request( access_t *p_access, uint64_t i_tell )
net_Printf( p_access, p_sys->fd, pvs, "Referer: %s\r\n",
p_sys->psz_referrer);
}
+#ifdef HAVE_ZLIB_H
+ if ( p_sys->b_shouldcompress )
+ {
+ net_Printf( p_access, p_sys->fd, pvs, "Accept-Encoding: gzip, deflate\r\n" );
+ }
+#endif
/* Offset */
if( p_sys->i_version == 1 && ! p_sys->b_continuous )
{
--
1.7.9
More information about the vlc-devel
mailing list