[Mplayer-cvslog] CVS: main/libmpdemux network.c,1.95,1.96

Roberto Togni CVS syncmail at mplayerhq.hu
Sat Apr 24 15:16:19 CEST 2004


CVS change done by Roberto Togni CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv18451

Modified Files:
	network.c 
Log Message:
Handle url redirection
Patch by adland


Index: network.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/network.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- network.c	19 Apr 2004 19:55:37 -0000	1.95
+++ network.c	24 Apr 2004 13:16:16 -0000	1.96
@@ -903,7 +903,9 @@
 int
 nop_streaming_start( stream_t *stream ) {
 	HTTP_header_t *http_hdr = NULL;
-	int fd;
+	char *next_url=NULL;
+	URL_t *rd_url=NULL;
+	int fd,ret;
 	if( stream==NULL ) return -1;
 
 	fd = stream->fd;
@@ -924,10 +926,36 @@
 					}
 				}
 				break;
+			// Redirect
+			case 301: // Permanently
+			case 302: // Temporarily
+				ret=-1;
+				next_url = http_get_field( http_hdr, "Location" );
+
+				if (next_url != NULL)
+					rd_url=url_new(next_url);
+
+				if (next_url != NULL && rd_url != NULL) {
+					mp_msg(MSGT_NETWORK,MSGL_STATUS,"Redirected: Using this url instead %s\n",next_url);
+							stream->streaming_ctrl->url=check4proxies(rd_url);
+					ret=nop_streaming_start(stream); //recursively get streaming started 
+				} else {
+					mp_msg(MSGT_NETWORK,MSGL_ERR,"Redirection failed\n");
+					closesocket( fd );
+					fd = -1;
+				}
+				return ret;
+				break;
+			case 401: //Authorization required
+			case 403: //Forbidden
+			case 404: //Not found
+			case 500: //Server Error
 			default:
-				mp_msg(MSGT_NETWORK,MSGL_ERR,"Server return %d: %s\n", http_hdr->status_code, http_hdr->reason_phrase );
+				mp_msg(MSGT_NETWORK,MSGL_ERR,"Server returned code %d: %s\n", http_hdr->status_code, http_hdr->reason_phrase );
 				closesocket( fd );
 				fd = -1;
+				return -1;
+				break;
 		}
 		stream->fd = fd;
 	} else {




More information about the MPlayer-cvslog mailing list