#include <assert.h>
+#ifdef HAVE_PROXY_H
+# include "proxy.h"
+#endif
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_UrlParse( &p_sys->proxy, psz, 0 );
free( psz );
}
-#ifdef HAVE_GETENV
+#ifdef HAVE_PROXY_H
+ else
+ {
+ pxProxyFactory *pf = px_proxy_factory_new();
+ if (pf)
+ {
+ char *buf;
+ int i;
+ i=asprintf(&buf, "%s://%s", p_access->psz_access, p_access->psz_path);
+ if (i >= 0)
+ {
+ msg_Dbg(p_access, "asking libproxy about url '%s'", buf);
+ char **proxies = px_proxy_factory_get_proxies(pf, buf);
+ if (proxies[0])
+ {
+ msg_Dbg(p_access, "libproxy suggest to use '%s'", proxies[0]);
+ if(strcmp(proxies[0],"direct://") != 0)
+ {
+ p_sys->b_proxy = true;
+ vlc_UrlParse( &p_sys->proxy, proxies[0], 0);
+ }
+ }
+ for(i=0;proxies[i];i++) free(proxies[i]);
+ free(proxies);
+ free(buf);
+ }
+ px_proxy_factory_free(pf);
+ }
+ else
+ {
+ msg_Err(p_access, "Allocating memory for libproxy failed");
+ }
+ }
+#elif HAVE_GETENV
else
{
psz = getenv( "http_proxy" );
Disconnect( p_access );
+ if( p_access->info.i_size
+ && (uint64_t)i_pos >= (uint64_t)p_access->info.i_size ) {
+ msg_Err( p_access, "seek to far" );
+ int retval = Seek( p_access, p_access->info.i_size - 1 );
+ if( retval == VLC_SUCCESS ) {
+ uint8_t p_buffer[2];
+ Read( p_access, p_buffer, 1);
+ p_access->info.b_eof = false;
+ }
+ return retval;
+ }
if( Connect( p_access, i_pos ) )
{
msg_Err( p_access, "seek failed" );
if( p_sys->i_version == 1 )
{
net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs,
- "Range: bytes=%"PRId64"-\r\n", i_tell );
+ "Range: bytes=%"PRIu64"-\r\n", i_tell );
}
/* Cookies */
net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, "Icy-MetaData: 1\r\n" );
- if( p_sys->b_continuous )
- {
- net_Printf( VLC_OBJECT( p_access ), p_sys->fd, pvs,
- "Connection: Keep-Alive\r\n" );
- }
- else if( p_sys->i_version == 1 )
- {
- net_Printf( VLC_OBJECT( p_access ), p_sys->fd, pvs,
- "Connection: Close\r\n");
- }
-
if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, "\r\n" ) < 0 )
{
msg_Err( p_access, "failed to send request" );
free( psz );
}
+ if(p_sys->i_remaining == 0 && (p_access->info.i_size == -1 || p_access->info.i_size == i_tell)) {
+ Disconnect( p_access );
+ }
return VLC_SUCCESS;
error: