Permalink
Browse files

accept gzip response (updated to httpclient 4.1.2)

  • Loading branch information...
biafra23 committed Apr 21, 2012
1 parent de3dbd1 commit 90e10bb12f2c2b923eb2ad6ce388992a458c23c7
Showing with 250 additions and 199 deletions.
  1. +2 −3 AmenLib/pom.xml
  2. +44 −4 AmenLib/src/main/java/com.jaeckel/amenoid/api/AmenHttpClient.java
  3. +204 −192 pom.xml
View
@@ -46,12 +46,12 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>4.0.1</version>
+ <version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
- <version>4.0.1</version>
+ <version>4.1.2</version>
</dependency>
<dependency>
@@ -88,7 +88,6 @@
<version>0.9.22</version>
<scope>runtime</scope>
</dependency>
-
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
@@ -1,5 +1,12 @@
package com.jaeckel.amenoid.api;
+import java.io.InputStream;
+import java.security.KeyStore;
+
+import javax.net.ssl.SSLException;
+
+import org.apache.http.client.protocol.RequestAcceptEncoding;
+import org.apache.http.client.protocol.ResponseContentEncoding;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
@@ -9,10 +16,7 @@
import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
-
-import javax.net.ssl.SSLException;
-import java.io.InputStream;
-import java.security.KeyStore;
+import org.apache.http.protocol.BasicHttpProcessor;
/**
* User: biafra
@@ -64,6 +68,28 @@ private SSLSocketFactory newSslSocketFactory() {
// sf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
// final X509HostnameVerifier delegate = sf.getHostnameVerifier();
// if (!(delegate instanceof MyVerifier)) {
+
+// X509HostnameVerifier verifier = new X509HostnameVerifier() {
+//
+// @Override
+// public void verify(String string, SSLSocket ssls) throws IOException {
+// }
+//
+// @Override
+// public void verify(String string, X509Certificate xc) throws SSLException {
+// }
+//
+// @Override
+// public void verify(String string, String[] strings, String[] strings1) throws SSLException {
+// }
+//
+// @Override
+// public boolean verify(String string, SSLSession ssls) {
+// return true;
+// }
+// };
+//
+// sf.setHostnameVerifier(verifier);
sf.setHostnameVerifier(new MyVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER));
// }
@@ -73,6 +99,19 @@ private SSLSocketFactory newSslSocketFactory() {
}
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected BasicHttpProcessor createHttpProcessor() {
+ //for gzip stuff
+ BasicHttpProcessor result = super.createHttpProcessor();
+
+ result.addRequestInterceptor(new RequestAcceptEncoding());
+ result.addResponseInterceptor(new ResponseContentEncoding());
+
+ return result;
+ }
}
@@ -98,6 +137,7 @@ public void verify(String host, String[] cns, String[] subjectAlts)
cn.substring(2)}, subjectAlts);
ok = true;
} catch (Exception e1) {
+ e1.printStackTrace();
}
}
}
Oops, something went wrong.

0 comments on commit 90e10bb

Please sign in to comment.