apache-httpclient-4.x

Apache HTTP connection with Android 6.0 (Marshmallow)

我们两清 提交于 2019-11-26 20:46:06
Is there is any way to include the Apache library directly in Gradle to make it work with Android 6.0 ? I've tried to include the libraries like that: compile 'org.apache.httpcomponents:httpcore:4.4.1' compile 'org.apache.httpcomponents:httpclient:4.5' And Android Studio couldn't manage to find the following import: import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.Credentials; import org.apache.http.auth.MalformedChallengeException; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.impl.auth.DigestScheme; This page discusses the

Getting NoSuchFieldError INSTANCE org/apache/http/message/BasicHeaderValueParser

我们两清 提交于 2019-11-26 20:17:19
I'm working on an app on Android. I'm using httpcore 4.3.3. I get this when I try to use ContentType.parse(string) java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicHeaderValueParser; in class Lorg/apache/http/message/BasicHeaderValueParser; or its superclasses (declaration of 'org.apache.http.message.BasicHeaderValueParser' appears in /system/framework/ext.jar) I've done some googling and I understand why I'm getting the error, but I'm unsure how to fix it. From what I've read, it seems that ContentType tries to make use of the BasicHeaderValueParser

Java http clients and POODLE

[亡魂溺海] 提交于 2019-11-26 20:17:11
问题 Regarding the POODLE vulnerability, if I understand it correctly, it requires a client that automatically downgrades TLS protocol to SSLv3 when failing to establish a secure channel with a server using higher version protocol advertised by the server. Do the common java HTTP client libraries, specifically javax.net.ssl.HttpsURLConnection and Apache HttpClient, automatically downgrade the TLS protocol when failing to establish TLS session with a server? If not, am I correct that they are

How to set TLS version on apache HttpClient

人盡茶涼 提交于 2019-11-26 20:01:51
How can I change the supported TLS versions on my HttpClient? I'm doing: SSLContext sslContext = SSLContext.getInstance("TLSv1.1"); sslContext.init( keymanagers.toArray(new KeyManager[keymanagers.size()]), null, null); SSLSocketFactory socketFactory = new SSLSocketFactory(sslContext, new String[]{"TLSv1.1"}, null, null); Scheme scheme = new Scheme("https", 443, socketFactory); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(scheme); BasicClientConnectionManager cm = new BasicClientConnectionManager(schemeRegistry); httpClient = new DefaultHttpClient(cm); But when

commons httpclient - Adding query string parameters to GET/POST request

血红的双手。 提交于 2019-11-26 19:39:35
问题 I am using commons HttpClient to make an http call to a Spring servlet. I need to add a few parameters in the query string. So I do the following: HttpRequestBase request = new HttpGet(url); HttpParams params = new BasicHttpParams(); params.setParameter("key1", "value1"); params.setParameter("key2", "value2"); params.setParameter("key3", "value3"); request.setParams(params); HttpClient httpClient = new DefaultHttpClient(); httpClient.execute(request); However when i try to read the parameter

Trusting all certificates with okHttp

半城伤御伤魂 提交于 2019-11-26 19:22:28
For testing purposes, I'm trying to add a socket factory to my okHttp client that trusts everything while a proxy is set. This has been done many times over, but my implementation of a trusting socket factory seems to be missing something: class TrustEveryoneManager implements X509TrustManager { @Override public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { } @Override public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { } @Override public java.security.cert

Write in body request with HttpClient

。_饼干妹妹 提交于 2019-11-26 19:05:23
问题 I want to write the body of a request with XML content-type but I don't know how with HttpClient Object ( http://hc.apache.org/httpclient-3.x/apidocs/index.html ) DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpRequest = new HttpPost(this.url); httpRequest.setHeader("Content-Type", "application/xml"); And I don't know how to continue to write the body with my XML ... 回答1: If your xml is written by java.lang.String you can just using HttpClient in this way public void post

Apache HttpClient 4.0.3 - how do I set cookie with sessionID for POST request?

ⅰ亾dé卋堺 提交于 2019-11-26 18:39:10
can you tell me how to store jsessionid in cookie, so it can be passed to the servlet with post request? I'm using Apache HttpClient version 4.0.3. All the solutions I've found explains how to do this with HttpClient 3.1. I've read tutorial and tried this, but it isn't working. HttpPost httppost = new HttpPost(postData); CookieStore cookieStore = new BasicCookieStore(); BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", getSessionId()); cookieStore.addCookie(cookie); client.setCookieStore(cookieStore); response = client.execute(httppost); Edit - further explanations I'm connecting

HttpClient 4.0.1 - how to release connection?

萝らか妹 提交于 2019-11-26 18:33:21
I have a loop over a bunch of URLs, for each one I'm doing the following: private String doQuery(String url) { HttpGet httpGet = new HttpGet(url); setDefaultHeaders(httpGet); // static method HttpResponse response = httpClient.execute(httpGet); // httpClient instantiated in constructor int rc = response.getStatusLine().getStatusCode(); if (rc != 200) { // some stuff... return; } HttpEntity entity = response.getEntity(); if (entity == null) { // some stuff... return; } // process the entity, get input stream etc } The first query is fine, the second throws this exception: Exception in thread

HttpClient Post with progress and MultipartEntityBuilder

六月ゝ 毕业季﹏ 提交于 2019-11-26 16:46:45
问题 I try to implement an progress while uploading an file with HttpClient 4.3.3 and MultipartEntityBuilder So actually i execute a post request with the following code HttpClientBuilder builder = HttpClientBuilder.create(); HttpClient httpClient = builder.build(); HttpPost httpPost = new HttpPost(uploadUrl); MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create(); entityBuilder.addPart("filea", new FileBody(filea)); entityBuilder.addPart("fileb", new FileBody(fileb)); final