Changeset 2c16687563b6e6096f5621db56917d9ef05424b2
- Timestamp:
- 22/06/08 19:31:07 (5 months ago)
- git-parent:
- Files:
-
- modules/access/http.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/access/http.c
ra735127 r2c16687 189 189 char *psz_icy_title; 190 190 191 int i_remaining;191 int64_t i_remaining; 192 192 193 193 bool b_seekable; … … 195 195 bool b_continuous; 196 196 bool b_pace_control; 197 bool b_persist; 197 198 198 199 vlc_array_t * cookies; … … 280 281 p_sys->psz_icy_title = NULL; 281 282 p_sys->i_remaining = 0; 283 p_sys->b_persist = false; 284 p_access->info.i_size = -1; 285 p_access->info.i_pos = 0; 286 p_access->info.b_eof = false; 282 287 283 288 p_sys->cookies = saved_cookies; … … 639 644 } 640 645 641 if( p_access->info.i_size > 0 &&646 if( p_access->info.i_size >= 0 && 642 647 i_len + p_access->info.i_pos > p_access->info.i_size ) 643 648 { … … 683 688 } 684 689 } 685 686 if( p_sys->b_continuous && (ssize_t)i_len > p_sys->i_remaining ) 687 { 690 else if( p_access->info.i_size != -1 && (int64_t)i_len > p_sys->i_remaining) { 688 691 /* Only ask for the remaining length */ 689 int i_new_len = p_sys->i_remaining; 690 if( i_new_len == 0 ) 691 { 692 Request( p_access, 0 ); 693 i_read = Read( p_access, p_buffer, i_len ); 694 return i_read; 695 } 696 i_len = i_new_len; 697 } 692 i_len = (size_t)p_sys->i_remaining; 693 if(i_len == 0) { 694 p_access->info.b_eof = true; 695 return 0; 696 } 697 } 698 698 699 699 700 if( p_sys->i_icy_meta > 0 && p_access->info.i_pos > 0 ) … … 765 766 } 766 767 767 if( p_ sys->b_continuous)768 if( p_access->info.i_size != -1 ) 768 769 { 769 770 p_sys->i_remaining -= i_read; … … 1008 1009 p_sys->psz_icy_genre = NULL; 1009 1010 p_sys->psz_icy_title = NULL; 1010 1011 p_access->info.i_size = 0; 1011 p_sys->i_remaining = 0; 1012 p_sys->b_persist = false; 1013 1014 p_access->info.i_size = -1; 1012 1015 p_access->info.i_pos = i_tell; 1013 1016 p_access->info.b_eof = false; … … 1107 1110 char *psz ; 1108 1111 v_socket_t *pvs = p_sys->p_vs; 1109 1112 bool b_connection_close = false; 1113 p_sys->b_persist = false; 1114 1115 p_sys->i_remaining = 0; 1110 1116 if( p_sys->b_proxy ) 1111 1117 { … … 1150 1156 p_sys->psz_user_agent ); 1151 1157 /* Offset */ 1152 if( p_sys->i_version == 1 ) 1153 { 1158 if( p_sys->i_version == 1 && ! p_sys->b_continuous ) 1159 { 1160 p_sys->b_persist = true; 1154 1161 net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, 1155 1162 "Range: bytes=%"PRIu64"-\r\n", i_tell ); … … 1194 1201 1195 1202 1196 if( p_sys->b_continuous )1197 {1198 net_Printf( VLC_OBJECT( p_access ), p_sys->fd, pvs,1199 "Connection: Keep-Alive\r\n" );1200 }1201 else if( p_sys->i_version == 1 )1202 {1203 net_Printf( VLC_OBJECT( p_access ), p_sys->fd, pvs,1204 "Connection: Close\r\n");1205 }1206 1207 1203 if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, "\r\n" ) < 0 ) 1208 1204 { … … 1294 1290 if( !strcasecmp( psz, "Content-Length" ) ) 1295 1291 { 1296 if( p_sys->b_continuous ) 1297 { 1298 p_access->info.i_size = -1; 1299 msg_Dbg( p_access, "this frame size=%lld", atoll(p ) ); 1300 p_sys->i_remaining = atoll( p ); 1301 } 1302 else 1303 { 1304 p_access->info.i_size = i_tell + atoll( p ); 1305 msg_Dbg( p_access, "stream size=%"PRId64, p_access->info.i_size ); 1292 int64_t i_size = i_tell + (p_sys->i_remaining = atoll( p )); 1293 if(i_size > p_access->info.i_size) { 1294 p_access->info.i_size = i_size; 1295 } 1296 msg_Dbg( p_access, "this frame size=%"PRId64, p_sys->i_remaining ); 1297 } 1298 else if( !strcasecmp( psz, "Content-Range" ) ) { 1299 int64_t i_ntell = i_tell; 1300 int64_t i_nend = (p_access->info.i_size > 0)?(p_access->info.i_size - 1):i_tell; 1301 int64_t i_nsize = p_access->info.i_size; 1302 sscanf(p,"bytes %"PRId64"-%"PRId64"/%"PRId64,&i_ntell,&i_nend,&i_nsize); 1303 if(i_nend > i_ntell ) { 1304 p_access->info.i_pos = i_ntell; 1305 p_sys->i_remaining = i_nend+1-i_ntell; 1306 int64_t i_size = (i_nsize > i_nend) ? i_nsize : (i_nend + 1); 1307 if(i_size > p_access->info.i_size) { 1308 p_access->info.i_size = i_size; 1309 } 1310 msg_Dbg( p_access, "stream size=%"PRId64",pos=%"PRId64",remaining=%"PRId64,i_nsize,i_ntell,p_sys->i_remaining); 1311 } 1312 } 1313 else if( !strcasecmp( psz, "Connection" ) ) { 1314 msg_Dbg( p_access, "Connection: %s",p ); 1315 int i = -1; 1316 sscanf(p, "close%n",&i); 1317 if( i >= 0 ) { 1318 p_sys->b_persist = false; 1306 1319 } 1307 1320 } … … 1456 1469 1457 1470 free( psz ); 1471 } 1472 /* We close the stream for zero length data, unless of course the 1473 * server has already promised to do this for us. 1474 */ 1475 if( p_access->info.i_size != -1 && p_sys->i_remaining == 0 && p_sys->b_persist ) { 1476 Disconnect( p_access ); 1458 1477 } 1459 1478 return VLC_SUCCESS;
