[MPlayer-cvslog] r20800 - in trunk/stream: http.c url.c url.h

reimar subversion at mplayerhq.hu
Wed Nov 8 23:42:31 CET 2006


Author: reimar
Date: Wed Nov  8 23:42:31 2006
New Revision: 20800

Modified:
   trunk/stream/http.c
   trunk/stream/url.c
   trunk/stream/url.h

Log:
Support URL redirections that do not specify full URL.
Fixes crash with mplayer -playlist http://www.radioseven.se/radioseven.pls.


Modified: trunk/stream/http.c
==============================================================================
--- trunk/stream/http.c	(original)
+++ trunk/stream/http.c	Wed Nov  8 23:42:31 2006
@@ -835,8 +835,7 @@
 				next_url = http_get_field( http_hdr, "Location" );
 				if( next_url!=NULL ) {
 					closesocket( fd );
-					url_free( url );
-					stream->streaming_ctrl->url = url = url_new( next_url );
+					stream->streaming_ctrl->url = url_redirect( &url, next_url );
 					http_free( http_hdr );
 					redirect = 1;	
 				}

Modified: trunk/stream/url.c
==============================================================================
--- trunk/stream/url.c	(original)
+++ trunk/stream/url.c	Wed Nov  8 23:42:31 2006
@@ -19,6 +19,25 @@
 #define SIZE_MAX ((size_t)-1)
 #endif
 
+URL_t *url_redirect(URL_t **url, const char *redir) {
+  URL_t *u = *url;
+  URL_t *res;
+  if (!strchr(redir, '/')) {
+    char *tmp;
+    char *newurl = malloc(strlen(u->url) + strlen(redir) + 1);
+    strcpy(newurl, u->url);
+    tmp = strrchr(newurl, '/');
+    if (tmp) tmp[1] = 0;
+    strcat(newurl, redir);
+    res = url_new(newurl);
+    free(newurl);
+  } else
+    res = url_new(redir);
+  url_free(u);
+  *url = res;
+  return res;
+}
+
 URL_t*
 url_new(const char* url) {
 	int pos1, pos2,v6addr = 0;

Modified: trunk/stream/url.h
==============================================================================
--- trunk/stream/url.h	(original)
+++ trunk/stream/url.h	Wed Nov  8 23:42:31 2006
@@ -19,6 +19,7 @@
 	char *password;
 } URL_t;
 
+URL_t *url_redirect(URL_t **url, const char *redir);
 URL_t* url_new(const char* url);
 void   url_free(URL_t* url);
 



More information about the MPlayer-cvslog mailing list