comparison stream/http.c @ 30357:3fdf04500df2

Handle Content-Length also when Content-Type is not set. Based on patch by Yuriy Kaminskiy [yumkam mail ru]
author reimar
date Sat, 23 Jan 2010 11:14:18 +0000
parents 5cd7eb2e34c0
children ce0122361a39
comparison
equal deleted inserted replaced
30356:5cd7eb2e34c0 30357:3fdf04500df2
741 int res = STREAM_UNSUPPORTED; 741 int res = STREAM_UNSUPPORTED;
742 int redirect = 0; 742 int redirect = 0;
743 int auth_retry=0; 743 int auth_retry=0;
744 int seekable=0; 744 int seekable=0;
745 char *content_type; 745 char *content_type;
746 const char *content_length;
746 char *next_url; 747 char *next_url;
747 URL_t *url = stream->streaming_ctrl->url; 748 URL_t *url = stream->streaming_ctrl->url;
748 749
749 do 750 do
750 { 751 {
814 } 815 }
815 816
816 // Assume standard http if not ICY 817 // Assume standard http if not ICY
817 switch( http_hdr->status_code ) { 818 switch( http_hdr->status_code ) {
818 case 200: // OK 819 case 200: // OK
820 content_length = http_get_field(http_hdr, "Content-Length");
821 if (content_length) {
822 mp_msg(MSGT_NETWORK,MSGL_V,"Content-Length: [%s]\n", content_length);
823 stream->end_pos = atoll(content_length);
824 }
819 // Look if we can use the Content-Type 825 // Look if we can use the Content-Type
820 content_type = http_get_field( http_hdr, "Content-Type" ); 826 content_type = http_get_field( http_hdr, "Content-Type" );
821 if( content_type!=NULL ) { 827 if( content_type!=NULL ) {
822 char *content_length = NULL;
823 mp_msg(MSGT_NETWORK,MSGL_V,"Content-Type: [%s]\n", content_type ); 828 mp_msg(MSGT_NETWORK,MSGL_V,"Content-Type: [%s]\n", content_type );
824 if( (content_length = http_get_field(http_hdr, "Content-Length")) != NULL) {
825 mp_msg(MSGT_NETWORK,MSGL_V,"Content-Length: [%s]\n", http_get_field(http_hdr, "Content-Length"));
826 stream->end_pos = atoll(content_length);
827 }
828 // Check in the mime type table for a demuxer type 829 // Check in the mime type table for a demuxer type
829 i = 0; 830 i = 0;
830 while(mime_type_table[i].mime_type != NULL) { 831 while(mime_type_table[i].mime_type != NULL) {
831 if( !strcasecmp( content_type, mime_type_table[i].mime_type ) ) { 832 if( !strcasecmp( content_type, mime_type_table[i].mime_type ) ) {
832 *file_format = mime_type_table[i].demuxer_type; 833 *file_format = mime_type_table[i].demuxer_type;