summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorbertrand <bertrand@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-06-23 09:17:52 +0000
committerbertrand <bertrand@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-06-23 09:17:52 +0000
commit9f6e8b15091302dffb4f526d5a9bf0bc3bfd4fc5 (patch)
tree8cbe1bd88f52a7216b6074171888dba7e3210658 /libmpdemux
parentf83fbf33c3710c5efa2d376a73560cb7077949ee (diff)
downloadmpv-9f6e8b15091302dffb4f526d5a9bf0bc3bfd4fc5.tar.bz2
mpv-9f6e8b15091302dffb4f526d5a9bf0bc3bfd4fc5.tar.xz
Added HTTP basic authentication support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6516 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/network.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/libmpdemux/network.c b/libmpdemux/network.c
index d4393ba618..8d7a0ca3cc 100644
--- a/libmpdemux/network.c
+++ b/libmpdemux/network.c
@@ -275,6 +275,7 @@ http_send_request( URL_t *url ) {
http_set_field( http_hdr, str);
http_set_field( http_hdr, "User-Agent: MPlayer/"VERSION);
http_set_field( http_hdr, "Connection: closed");
+ http_add_basic_authentication( http_hdr, url->username, url->password );
if( http_build_request( http_hdr )==NULL ) {
return -1;
}
@@ -492,6 +493,42 @@ extension=NULL;
redirect = 1;
}
break;
+ case 401: // Authorization required
+ {
+ char username[50], password[50];
+ char *aut;
+ aut = http_get_field(http_hdr, "WWW-Authenticate");
+ if( aut!=NULL ) {
+ char *aut_space;
+ aut_space = strstr(aut, "realm=");
+ if( aut_space!=NULL ) aut_space += 6;
+ mp_msg(MSGT_NETWORK,MSGL_ERR,"Authorization required for %s, please enter:\n", aut_space);
+ } else {
+ mp_msg(MSGT_NETWORK,MSGL_ERR,"Authorization required, please enter:\n");
+ }
+ mp_msg(MSGT_NETWORK,MSGL_ERR,"username: ");
+ // FIXME
+ scanf("%s", username);
+ printf("%s\n", username);
+ mp_msg(MSGT_NETWORK,MSGL_ERR,"password: ");
+ // FIXME
+ scanf("%s", password);
+ printf("%s\n", password);
+ url->username = (char*)malloc(strlen(username)+1);
+ if( url->username==NULL ) {
+ mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+ return -1;
+ }
+ strcpy(url->username, username);
+ url->password = (char*)malloc(strlen(password)+1);
+ if( url->password==NULL ) {
+ mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+ return -1;
+ }
+ strcpy(url->password, password);
+ redirect = 1;
+ break;
+ }
default:
mp_msg(MSGT_NETWORK,MSGL_ERR,"Server returned %d: %s\n", http_hdr->status_code, http_hdr->reason_phrase );
return -1;