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

536 questions
181
votes
9 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
  • 26,321
  • 24
  • 115
  • 201
166
votes
36 answers

Disable HttpClient logging

I´m 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 need…
Matt Baker
  • 3,394
  • 3
  • 25
  • 35
134
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,815
  • 7
  • 20
  • 31
112
votes
4 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
  • 18,822
  • 21
  • 92
  • 144
96
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
  • 47,586
  • 132
  • 466
  • 875
79
votes
6 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
  • 7,684
  • 12
  • 41
  • 56
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
56
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
10 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,243
  • 2
  • 11
  • 11
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,370
  • 8
  • 36
  • 63
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,769
  • 16
  • 61
  • 86
42
votes
5 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
  • 52,998
  • 69
  • 209
  • 339
41
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,338
  • 10
  • 45
  • 54
40
votes
5 answers

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

I found these system settings http.proxyHost and http.proxyPort are 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
  • 83,087
  • 147
  • 309
  • 426
35
votes
8 answers

Does Apache Commons HttpClient support GZIP?

Does the library Apache Commons HttpClient support Gzip? We wanted to use enable gzip compression on our Apache server to speed up the client/server communications (we have a php page that allows our Android application to sync files with the…
1
2 3
35 36