Permalink
Browse files

The request part of the final URL was not being appended... oops! O:)

  • Loading branch information...
1 parent 13eae95 commit 79afd8f20fd7e6b7b79da2c01e658571d15d26b6 @skarcha committed Feb 16, 2011
Showing with 14 additions and 12 deletions.
  1. +14 −12 src/com/skarcha/nobrowser/Main.java
@@ -5,6 +5,7 @@
import java.net.URISyntaxException;
import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
@@ -179,6 +180,7 @@ private boolean isShortener (String url) {
private String getFinalURL (String url) throws IOException, IOException {
HttpHost target;
+ HttpRequest request;
// Youtu.be special case
if (url.startsWith("http://youtu.be")) {
@@ -195,20 +197,20 @@ private String getFinalURL (String url) throws IOException, IOException {
HttpClient httpclient = new DefaultHttpClient();
try {
- HttpHead httphead = new HttpHead(url);
- HttpContext localContext = new BasicHttpContext();
- HttpResponse response = httpclient.execute(httphead, localContext);
- target = (HttpHost) localContext.getAttribute(
- ExecutionContext.HTTP_TARGET_HOST);
- } finally {
- httpclient.getConnectionManager().shutdown();
- }
+ HttpHead httphead = new HttpHead(url);
+ HttpContext localContext = new BasicHttpContext();
+ HttpResponse response = httpclient.execute(httphead, localContext);
+ target = (HttpHost) localContext.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
+ request = (HttpRequest) localContext.getAttribute(ExecutionContext.HTTP_REQUEST);
+ } finally {
+ httpclient.getConnectionManager().shutdown();
+ }
- if (target == null) {
- return null;
- }
+ if (target == null) {
+ return null;
+ }
- return target.toString();
+ return target.toString() + request.getRequestLine().getUri();
}
private void getPrefs() {

0 comments on commit 79afd8f

Please sign in to comment.