]> git.sesse.net Git - vlc/blobdiff - modules/access/http.c
* Fixed URLs here and there.
[vlc] / modules / access / http.c
index ecfc62041ff00768c70a7b6f57ed6e41bd5f3160..db10329e7839a25768b237e257140e00b7b128ba 100644 (file)
@@ -2,7 +2,7 @@
  * http.c: HTTP access plug-in
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: http.c,v 1.43 2003/08/02 19:30:35 bigben Exp $
+ * $Id: http.c,v 1.47 2003/12/21 23:32:58 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -25,7 +25,6 @@
  * Preamble
  *****************************************************************************/
 #include <stdlib.h>
-#include <string.h>
 #include <vlc/vlc.h>
 #include <vlc/input.h>
 
@@ -74,7 +73,7 @@ static ssize_t Read    ( input_thread_t *, byte_t *, size_t );
 #define PROXY_TEXT N_("Specify an HTTP proxy")
 #define PROXY_LONGTEXT N_( \
     "Specify an HTTP proxy to use. It must be in the form " \
-    "http://myproxy.mydomain:myport. If none is specified, the HTTP_PROXY " \
+    "http://myproxy.mydomain:myport/. If none is specified, the HTTP_PROXY " \
     "environment variable will be tried." )
 
 #define CACHING_TEXT N_("Caching value in ms")
@@ -151,6 +150,7 @@ static int HTTPConnect( input_thread_t * p_input, off_t i_tell )
                    "Range: bytes="I64Fd"-\r\n"
                    HTTP_USERAGENT
                    "%s"
+                   "Connection: Close\r\n"
                    HTTP_END,
                    p_access_data->psz_buffer, i_tell, p_access_data->psz_auth_string );
     }
@@ -160,6 +160,7 @@ static int HTTPConnect( input_thread_t * p_input, off_t i_tell )
                    "%s"
                    HTTP_USERAGENT
                    "%s"
+                   "Connection: Close\r\n"
                    HTTP_END,
                    p_access_data->psz_buffer, p_access_data->psz_auth_string );
     }
@@ -234,6 +235,17 @@ static int HTTPConnect( input_thread_t * p_input, off_t i_tell )
         return VLC_EGENERIC;
     }
 
+    /* Check for buggy Icecast servers */
+    if( strstr( psz_parser , "x-audiocast") )
+    {
+        i_protocol = ICY_PROTOCOL;
+        if( !p_input->psz_demux || !*p_input->psz_demux  )
+        {
+            msg_Info( p_input, "ICY server found, mp3 demuxer selected" );
+            p_input->psz_demux = "mp3";    // FIXME strdup ?
+        }
+    }
+
     /* Check the HTTP return code */
     i_code = atoi( (char*)psz_parser );
     msg_Dbg( p_input, "%s server replied: %i",
@@ -313,18 +325,8 @@ static int HTTPConnect( input_thread_t * p_input, off_t i_tell )
         if( !strcasecmp( psz_line, "Content-Length" ) )
         {
             off_t i_size = 0;
-#ifdef HAVE_ATOLL
-            i_size = i_tell + atoll( psz_value );
-#else
-            int sign = 1;
 
-            if( *psz_value == '-' ) sign = -1;
-            while( *psz_value >= '0' && *psz_value <= '9' )
-            {
-                i_size = i_size * 10 + *psz_value++ - '0';
-            }
-            i_size = i_tell + ( i_size * sign );
-#endif
+            i_size = i_tell + atoll( psz_value );
             msg_Dbg( p_input, "stream size is "I64Fd, i_size );
 
             vlc_mutex_lock( &p_input->stream.stream_lock );