summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2014-03-17 00:24:01 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2014-03-17 00:24:01 +0100
commitf1e88a917ec3d4e776a0aa41e904fdea6dc10a1a (patch)
tree759a7e5851be07517be66441e355594ab5a03524
parentbed57245b3ce454e714b5d5b22c8167ad7b986c8 (diff)
parent1feb62ae853443168c27f088fcc30d5b8feb6507 (diff)
downloadAntennaPod-f1e88a917ec3d4e776a0aa41e904fdea6dc10a1a.zip
Merge branch 'BasicAuth' of git://github.com/cszucko/AntennaPod into cszucko-BasicAuth
-rw-r--r--src/de/danoeh/antennapod/service/download/HttpDownloader.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/de/danoeh/antennapod/service/download/HttpDownloader.java b/src/de/danoeh/antennapod/service/download/HttpDownloader.java
index fc2b3178b..1ffea19d5 100644
--- a/src/de/danoeh/antennapod/service/download/HttpDownloader.java
+++ b/src/de/danoeh/antennapod/service/download/HttpDownloader.java
@@ -11,8 +11,10 @@ import org.apache.commons.io.IOUtils;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
+import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.auth.BasicScheme;
import java.io.*;
import java.net.*;
@@ -44,6 +46,15 @@ public class HttpDownloader extends Downloader {
InputStream connection = null;
try {
HttpGet httpGet = new HttpGet(getURIFromRequestUrl(request.getSource()));
+ String userInfo = httpGet.getURI().getUserInfo();
+ if (userInfo != null) {
+ String[] parts = userInfo.split(":");
+ if (parts.length == 2) {
+ httpGet.addHeader(BasicScheme.authenticate(
+ new UsernamePasswordCredentials(parts[0], parts[1]),
+ "UTF-8", false));
+ }
+ }
HttpResponse response = httpClient.execute(httpGet);
HttpEntity httpEntity = response.getEntity();
int responseCode = response.getStatusLine().getStatusCode();