Questions tagged [apache-commons-httpclient]

The HttpClient v3.x (or older) library from the Apache Commons project

For questions releated to the newer Apache HttpClient v4.x library, see

517 questions
176
votes
10 answers

Deprecated Java HttpClient - How hard can it be?

All I'm trying to do is download some JSON and deserialize it into an object. I haven't got as far as downloading the JSON yet. Almost every single HttpClient example I can find, including those on the apache site looks something like... import…
Basic
  • 25,223
  • 23
  • 108
  • 188
144
votes
32 answers

Disable HttpClient logging

I am using commons-httpclient 3.1 in an integration test suite. The default logging for HttpClient is extremely noisy and I can't seem to turn it off. I've tried following the instructions here but none of them make any difference. Mostly I just…
Matt Baker
  • 3,164
  • 3
  • 23
  • 34
128
votes
18 answers

How to handle invalid SSL certificates with Apache HttpClient?

I know, there are many different questions and so many answers about this problem... But I can't understand... I have: ubuntu-9.10-desktop-amd64 + NetBeans6.7.1 installed "as is" from off. rep. I need connecting to some site over the HTTPS. For this…
rauch
  • 1,755
  • 7
  • 18
  • 29
96
votes
3 answers

How to POST JSON request using Apache HttpClient?

I have something like the following: final String url = "http://example.com"; final HttpClient httpClient = new HttpClient(); final PostMethod postMethod = new PostMethod(url); postMethod.addRequestHeader("Content-Type",…
Noel Yap
  • 15,499
  • 17
  • 77
  • 123
88
votes
5 answers

Best Practice to Use HttpClient in Multithreaded Environment

For a while, I have been using HttpClient in a multithreaded environment. For every thread, when it initiates a connection, it will create a completely new HttpClient instance. Recently, I have discovered that, by using this approach, it can cause…
Cheok Yan Cheng
  • 49,649
  • 117
  • 410
  • 768
59
votes
8 answers

Android deprecated apache module (HttpClient, HttpResponse, etc.)

Android has deprecated the Apache module since API level 22, so my question is, how do I use, for example HttpResponse from the Apache library, not from Android SDK? The problem is that the're the same in both packages. But, for example, HttpGet is…
Evgeniy
  • 591
  • 1
  • 4
  • 4
55
votes
1 answer

How do Jersey-client and Apache HTTP Client compare?

First of all, I'm not trying to start a flame-war here. I know Jersey sufficiently well, but have hardly used httpclient. What are the key differences between jersey-client and Apache's httpclient? In what areas is one better than the other? Is…
54
votes
4 answers

Fixing HttpClient warning "Invalid expires attribute" using fluent API

I'm using the fluent API of HttpClient to make a GET request: String jsonResult = Request.Get(requestUrl) .connectTimeout(2000) .socketTimeout(2000) .execute().returnContent().asString(); But for each request I…
The Coding Monk
  • 6,777
  • 11
  • 38
  • 51
53
votes
3 answers

Apache http client or URLConnection

I need to download a web page on an android app and I am having a hard time deciding whether to use the android apache http client or java's URLConnection. Any thoughts?
Amit Raz
  • 5,013
  • 8
  • 33
  • 55
53
votes
9 answers

Preemptive Basic authentication with Apache HttpClient 4

Is there an easier way to setup the http client for preemptive basic authentication than what described here? In previous version (3.x) it used to be a simple method call (eg, httpClient.getParams().setAuthenticationPreemptive(true)). The main thing…
yossis
  • 1,213
  • 2
  • 11
  • 11
49
votes
5 answers

Duplicate files during packaging of APK app-debug-unaligned.apk

I got this error Duplicate files during packaging of APK app-debug-unaligned.apk when put 2 jar files : httpclient-4.3.5.jar httpmime-4.3.5.jar into the libs folder after Sync with Gradle and Run. If user 1 jar file - httpmime-4.3.5.jar, I will…
Huy Tower
  • 7,162
  • 13
  • 49
  • 81
41
votes
4 answers

Using Apache httpclient for https

I have enabled https in tomcat and have a self-signed certificate for server auth. I have created an http client using Apache httpClient. I have set a trust manager loading the server certificate. The http client can connect with server no problem.…
Cratylus
  • 49,824
  • 60
  • 195
  • 327
38
votes
2 answers

Using Apache HttpClient how to set the TIMEOUT on a request and response

I need to set time out for the Http Request we make to a service (not a web service). We are using Apache HTTP Client. I have added these 2 lines of code to set the time out on request and response to the service.…
pushya
  • 4,058
  • 9
  • 39
  • 52
37
votes
5 answers

Without changing code, how to force httpClient to use proxy by environment variables or JVM arguments

I found setting http.proxyHost and http.proxyPort is of no use to httpClient. How to force the httpClient to use proxy by environment variables or VM arguments or something like those without changing code?
user496949
  • 75,601
  • 138
  • 297
  • 413
33
votes
7 answers

Apache HttpClient on Android producing CertPathValidatorException (IssuerName != SubjectName)

I'm developing an Android application for accessing some battle.net (https://eu.battle.net) account data (for World of Warcraft) and I'm using the org.apache.http.client.HttpClient to do so. This is the code I'm using: public static final String…
Saran
  • 3,729
  • 3
  • 33
  • 54
1
2 3
34 35