summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorrtognimp <rtognimp@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-04-24 13:16:16 +0000
committerrtognimp <rtognimp@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-04-24 13:16:16 +0000
commit94e2c8385bf9bb43175f6bb44c265843f0a53ee5 (patch)
treeaa1cdbca71c780672bdb589007fd89418c1d881e /libmpdemux
parenta6cf3719226346c7c538a753082704809907650e (diff)
downloadmpv-94e2c8385bf9bb43175f6bb44c265843f0a53ee5.tar.bz2
mpv-94e2c8385bf9bb43175f6bb44c265843f0a53ee5.tar.xz
Handle url redirection
Patch by adland git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12269 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/network.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/libmpdemux/network.c b/libmpdemux/network.c
index 9694d48fb8..92c02f3bd1 100644
--- a/libmpdemux/network.c
+++ b/libmpdemux/network.c
@@ -903,7 +903,9 @@ nop_streaming_seek( int fd, off_t pos, streaming_ctrl_t *stream_ctrl ) {
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 @@ nop_streaming_start( stream_t *stream ) {
}
}
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 {