diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-12-19 01:19:54 +0100 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-12-19 01:19:54 +0100 |
commit | d23cc6dbac6f2b212d99453fddc0f20ccd178ab4 (patch) | |
tree | a43f86076f7d7332e8ea8c2e08b10e29cea6d5f3 | |
parent | 8292c2472059f33772d4dde3fb0e07884797278c (diff) | |
download | xine-lib-d23cc6dbac6f2b212d99453fddc0f20ccd178ab4.tar.gz xine-lib-d23cc6dbac6f2b212d99453fddc0f20ccd178ab4.tar.bz2 |
Only calculate proxyauth and auth when they are going to be used.
-rw-r--r-- | src/input/input_http.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/src/input/input_http.c b/src/input/input_http.c index bc9a819bd..96841593f 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -620,20 +620,9 @@ static int http_plugin_open (input_plugin_t *this_gen ) { int use_proxy; int proxyport; int mpegurl_redirect = 0; - char *auth = NULL; - char *proxyauth = NULL; use_proxy = this_class->proxyhost && strlen(this_class->proxyhost); - if (use_proxy) { - if (this_class->proxyuser && strlen(this_class->proxyuser)) { - http_plugin_basicauth (this_class->proxyuser, - this_class->proxypassword, - &proxyauth); - } - } - - if (!_x_parse_url(this->mrl, &this->proto, &this->host, &this->port, &this->user, &this->password, &this->uri)) { _x_message(this->stream, XINE_MSG_GENERAL_WARNING, "malformed url", NULL); @@ -644,10 +633,6 @@ static int http_plugin_open (input_plugin_t *this_gen ) { if (this->port == 0) this->port = DEFAULT_HTTP_PORT; - if (this->user && strlen(this->user)) { - http_plugin_basicauth (this->user, this->password, &auth); - } - if (this_class->proxyport == 0) proxyport = DEFAULT_HTTP_PORT; else @@ -678,8 +663,6 @@ static int http_plugin_open (input_plugin_t *this_gen ) { this->curpos = 0; if (this->fh == -1) { - free(proxyauth); - free(auth); return -2; } @@ -701,8 +684,6 @@ static int http_plugin_open (input_plugin_t *this_gen ) { if (res != XIO_READY) { _x_message(this->stream, XINE_MSG_NETWORK_UNREACHABLE, this->mrl, NULL); - free(proxyauth); - free(auth); return -3; } } @@ -728,17 +709,24 @@ static int http_plugin_open (input_plugin_t *this_gen ) { this->host); buflen = strlen(this->buf); - if (this_class->proxyuser && strlen(this_class->proxyuser)) { + if (use_proxy && this_class->proxyuser && strlen(this_class->proxyuser)) { + char *proxyauth; + http_plugin_basicauth (this_class->proxyuser, this_class->proxypassword, + &proxyauth); + snprintf (this->buf + buflen, BUFSIZE - buflen, "Proxy-Authorization: Basic %s\015\012", proxyauth); buflen = strlen(this->buf); - free(proxyauth); proxyauth = NULL; + free(proxyauth); } if (this->user && strlen(this->user)) { + char *auth; + http_plugin_basicauth (this->user, this->password, &auth); + snprintf (this->buf + buflen, BUFSIZE - buflen, "Authorization: Basic %s\015\012", auth); buflen = strlen(this->buf); - free(auth); auth = NULL; + free(auth); } snprintf(this->buf + buflen, BUFSIZE - buflen, |