add_integer( "http-caching", 4 * DEFAULT_PTS_DELAY / 1000, NULL,
CACHING_TEXT, CACHING_LONGTEXT, true )
change_safe()
- add_string( "http-user-agent", COPYRIGHT_MESSAGE , NULL, AGENT_TEXT,
- AGENT_LONGTEXT, true )
+ add_string( "http-user-agent", PACKAGE_NAME" "PACKAGE_VERSION, NULL,
+ AGENT_TEXT, AGENT_LONGTEXT, true )
change_safe()
add_bool( "http-reconnect", false, NULL, RECONNECT_TEXT,
RECONNECT_LONGTEXT, true )
"in registry." );
}
}
-#elif HAVE_GETENV
+#elif defined( HAVE_GETENV )
else
{
psz = getenv( "http_proxy" );
}
}
- msg_Dbg( p_access, "http: server='%s' port=%d file='%s",
- p_sys->url.psz_host, p_sys->url.i_port, p_sys->url.psz_path );
+ msg_Dbg( p_access, "http: server='%s' port=%d file='%s'",
+ p_sys->url.psz_host, p_sys->url.i_port,
+ p_sys->url.psz_path != NULL ? p_sys->url.psz_path : "" );
if( p_sys->b_proxy )
{
msg_Dbg( p_access, " proxy %s:%d", p_sys->proxy.psz_host,
return 0;
}
- if( p_sys->b_has_size &&
- i_len + p_access->info.i_pos > p_access->info.i_size )
+ if( p_sys->b_has_size )
{
- if( ( i_len = p_access->info.i_size - p_access->info.i_pos ) == 0 )
- {
- p_access->info.b_eof = true;
- return 0;
- }
+ /* Remaining bytes in the file */
+ uint64_t remainder = p_access->info.i_size - p_access->info.i_pos;
+ if( remainder < i_len )
+ i_len = remainder;
+
+ /* Remaining bytes in the response */
+ if( p_sys->i_remaining < i_len )
+ i_len = p_sys->i_remaining;
}
if( p_sys->b_chunked )
}
if( i_len > p_sys->i_chunk )
- {
i_len = p_sys->i_chunk;
- }
- }
- else if( p_sys->b_has_size && i_len > p_sys->i_remaining) {
- /* Only ask for the remaining length */
- i_len = p_sys->i_remaining;
- if(i_len == 0) {
- p_access->info.b_eof = true;
- return 0;
- }
}
+ if( i_len == 0 )
+ {
+ p_access->info.b_eof = true;
+ return 0;
+ }
if( p_sys->i_icy_meta > 0 && p_access->info.i_pos-p_sys->i_icy_offset > 0 )
{
if( i_read > 0 )
{
- p_access->info.i_pos += i_read;
-
if( p_sys->b_chunked )
{
p_sys->i_chunk -= i_read;
}
}
}
- else if( i_read <= 0 )
+ else
{
/*
* I very much doubt that this will work.
p_sys->b_reconnect = false;
i_read = Read( p_access, p_buffer, i_len );
p_sys->b_reconnect = true;
+
+ return i_read;
}
}
- if( i_read == 0 )
+ if( i_read <= 0 )
+ {
p_access->info.b_eof = true;
- if( i_read < 0 )
- p_sys->b_error = true;
+ if( i_read < 0 )
+ p_sys->b_error = true;
+ return 0;
+ }
}
+ assert( i_read >= 0 );
+ p_access->info.i_pos += i_read;
if( p_sys->b_has_size )
{
- assert( i_read <= p_sys->i_remaining );
+ assert( p_access->info.i_pos <= p_access->info.i_size );
+ assert( (unsigned)i_read <= p_sys->i_remaining );
p_sys->i_remaining -= i_read;
}
sscanf(p,"bytes %"SCNu64"-%"SCNu64"/%"SCNu64,&i_ntell,&i_nend,&i_nsize);
if(i_nend > i_ntell ) {
p_access->info.i_pos = i_ntell;
+ p_sys->i_icy_offset = i_ntell;
p_sys->i_remaining = i_nend+1-i_ntell;
int64_t i_size = (i_nsize > i_nend) ? i_nsize : (i_nend + 1);
if(i_size > p_access->info.i_size) {