From 90e10bb12f2c2b923eb2ad6ce388992a458c23c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dirk=20Ja=CC=88ckel?= Date: Sat, 21 Apr 2012 23:11:53 +0200 Subject: [PATCH] accept gzip response (updated to httpclient 4.1.2) --- AmenLib/pom.xml | 5 +- .../amenoid/api/AmenHttpClient.java | 48 ++- pom.xml | 396 +++++++++--------- 3 files changed, 250 insertions(+), 199 deletions(-) diff --git a/AmenLib/pom.xml b/AmenLib/pom.xml index 9e3dbd6..05c8ef3 100644 --- a/AmenLib/pom.xml +++ b/AmenLib/pom.xml @@ -46,12 +46,12 @@ org.apache.httpcomponents httpclient - 4.0.1 + 4.1.2 org.apache.httpcomponents httpcore - 4.0.1 + 4.1.2 @@ -88,7 +88,6 @@ 0.9.22 runtime - ${project.artifactId} diff --git a/AmenLib/src/main/java/com.jaeckel/amenoid/api/AmenHttpClient.java b/AmenLib/src/main/java/com.jaeckel/amenoid/api/AmenHttpClient.java index 7ca7ff1..dbccd10 100644 --- a/AmenLib/src/main/java/com.jaeckel/amenoid/api/AmenHttpClient.java +++ b/AmenLib/src/main/java/com.jaeckel/amenoid/api/AmenHttpClient.java @@ -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(); } } } diff --git a/pom.xml b/pom.xml index d15b397..2381498 100644 --- a/pom.xml +++ b/pom.xml @@ -1,207 +1,219 @@ - - 4.0.0 - com.jaeckel - amdroid-parent - 1.0-SNAPSHOT - pom - Amenoid - Parent - - AmenLib - AmDroid - AmDroidTest - - - - - com.google.android - android - 2.2.1 - provided - - - com.google.android - android-test - 2.2.1 - provided - - - - - - - - com.jayway.maven.plugins.android.generation2 - android-maven-plugin - true - - ${project.basedir}/AndroidManifest.xml - ${project.basedir}/assets - ${project.basedir}/res - ${project.basedir}/src/main/native - - 7 - - true - false - - - - maven-compiler-plugin - 2.3.2 - true - - 1.5 - 1.5 - - - - maven-enforcer-plugin - 1.0 - - - maven-release-plugin - 2.1 - - true - - - - maven-jarsigner-plugin - 1.2 - true - - true - - ${project.build.directory}/${project.build.finalName}.${project.packaging} - true - true - ${sign.keystore} - ${sign.alias} - ${sign.storepass} - ${sign.keypass} - - - - com.pyx4me - proguard-maven-plugin - 2.0.4 - + + 4.0.0 + com.jaeckel + amdroid-parent + 1.0-SNAPSHOT + pom + Amenoid - Parent + + AmenLib + AmDroid + AmDroidTest + + + - net.sf.proguard - proguard - 4.4 - runtime + com.google.android + android + 2.2.1 + provided - - - 4.4 - - - - - - - - release - - - performRelease - true - - - - - - maven-enforcer-plugin - - - enforce-signing-properties - - enforce - - - - - sign.keystore - The 'sign.keystore' property is missing. It must contain the path + + com.google.android + android-test + 2.2.1 + provided + + + org.apache.httpcomponents + httpclient + 4.1.2 + + + org.apache.httpcomponents + httpcore + 4.1.2 + + + + + + + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + true + + ${project.basedir}/AndroidManifest.xml + ${project.basedir}/assets + ${project.basedir}/res + ${project.basedir}/src/main/native + + 7 + + true + false + + + + maven-compiler-plugin + 2.3.2 + true + + 1.5 + 1.5 + + + + maven-enforcer-plugin + 1.0 + + + maven-release-plugin + 2.1 + + true + + + + maven-jarsigner-plugin + 1.2 + true + + true + + ${project.build.directory}/${project.build.finalName}.${project.packaging} + true + true + ${sign.keystore} + ${sign.alias} + ${sign.storepass} + ${sign.keypass} + + + + com.pyx4me + proguard-maven-plugin + 2.0.4 + + + net.sf.proguard + proguard + 4.4 + runtime + + + + 4.4 + + + + + + + + release + + + performRelease + true + + + + + + maven-enforcer-plugin + + + enforce-signing-properties + + enforce + + + + + sign.keystore + The 'sign.keystore' property is missing. It must contain the path to the keystore used to sign the application. - - - - ${sign.keystore} - - The 'sign.keystore' property does not point to a file. It must + + + + ${sign.keystore} + + The 'sign.keystore' property does not point to a file. It must contain the path to the keystore used to sign the application. - - - sign.alias - The 'sign.alias' property is missing. It must contain the key alias + + + sign.alias + The 'sign.alias' property is missing. It must contain the key alias used to sign the application. - - - sign.storepass - The 'sign.storepass' property is missing. It must contain the + + + sign.storepass + The 'sign.storepass' property is missing. It must contain the password of the keystore used to sign the application. - - - sign.keypass - The 'sign.keypass' property is missing. It must contain the + + + sign.keypass + The 'sign.keypass' property is missing. It must contain the password of the key used to sign the application. - - - - - - - - - - - linux - - - unix - - - - ${java.home}/jre/lib/rt.jar - ${java.home}/jre/lib/jsse.jar - - - - - mac - - - mac - - - - - - - ${java.home}/../Classes/classes.jar - ${java.home}/../Classes/jsse.jar - - - - windows - - - windows - - - - ${java.home}/jre/lib/rt.jar - ${java.home}/jre/lib/jsse.jar - - - + + mac + + + mac + + + + + + + ${java.home}/../Classes/classes.jar + ${java.home}/../Classes/jsse.jar + + + + windows + + + windows + + + + ${java.home}/jre/lib/rt.jar + ${java.home}/jre/lib/jsse.jar + + +