Questions tagged [apache-httpcomponents]

A Java library for interacting with HTTP services.

The Apache HttpComponents™ project is responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols.

See http://hc.apache.org/

For questions related to the HttpClient v4.x component, see

543 questions
364
votes
12 answers

java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion

I'm encountering this error when I use Android Studio to build my app. The APK is compiled, but when I attempt to run the app on Android P emulator, it will crash and throw the following error. Please see more details in the…
114
votes
17 answers

Ignoring SSL certificate in Apache HttpClient 4.3

How to ignore SSL certificate (trust all) for Apache HttpClient 4.3? All the answers that I have found on SO treat previous versions, and the API changed. Related: How to ignore SSL certificate errors in Apache HttpClient 4.0 How to handle invalid…
Jakub M.
  • 32,471
  • 48
  • 110
  • 179
56
votes
8 answers

Apache HttpClient Android (Gradle)

I have added this line to my build.gradle compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5' and I want to use MultipartEntityBuilder in my code. However Android studio doesn't add the library to my code. Can…
50
votes
5 answers

Apache HttpComponents HttpClient timeout

How do I set the connection timeout in httpcomponents httpclient? I have found the documentation at: http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html but it is not clear how these parameters are actually set. Also, an…
Landon Kuhn
  • 76,451
  • 45
  • 104
  • 130
43
votes
6 answers

Apache HttpClient (4.1 and newer): how to do basic authentication?

How do I add basic authentication for the default client of the httpClient library? I have seen examples where they use client.getCredentialProvider(), however I think all of this methods are for library version 4.0.1 or 3.x. Is there a new example…
Pablo
  • 3,433
  • 7
  • 44
  • 62
35
votes
1 answer

Using Spring REST template, either creating too many connections or slow

I have a RESTful service that works very fast. I am testing it on localhost. The client is using Spring REST template. I started by using a naive approach: RestTemplate restTemplate = new RestTemplate(Collections.singletonList(new…
MartinTeeVarga
  • 10,478
  • 12
  • 61
  • 98
33
votes
2 answers

Connection and connection request timeout

I am using Http Apache Components to perform the http interactions. I need to adjust my http client. For this purpose I have two parameters: connection timeout and connection request timeout. In library documentation and in source code(no comments…
mvb13
  • 1,514
  • 3
  • 18
  • 33
33
votes
4 answers

How to send parallel GET requests and wait for result responses?

I'm using apache http client within spring mvc 3.2.2 to send 5 get requests synchronously as illustrated. How can I send all of these asynchronously (in parallel) and wait for the requests to return in order to return a parsed payload string from…
genxgeek
  • 13,109
  • 38
  • 135
  • 217
32
votes
4 answers

java.lang.IllegalStateException: Request cannot be executed; I/O reactor status: STOPPED

I have a service that is expected to execute requests at ~5 or more requests/min. This service depends on Apache AsyncHttpClient. After every few minutes, the clients hits some condition which causes java.lang.IllegalStateException: Request cannot…
knash
  • 369
  • 1
  • 4
  • 8
27
votes
4 answers

Is there a way to get the String value of an HttpEntity when EntityUtils.toString() returns an exception?

I keep running into this situation where I get back a bad HTTP response (like a 400) but cannot look at the HttpEntity in the HttpResponse object. When I step through with the debugger, I can see that the entity has content (length > 0) and I can…
sangfroid
  • 3,733
  • 11
  • 38
  • 42
26
votes
5 answers

Setting time out in apache http client

I'm using Apache http client 4.3.2 to send get requests. What I have done is: private final RequestConfig requestConfig = RequestConfig.custom() .setConnectTimeout(1000) .setConnectionRequestTimeout(1000) …
Majid Azimi
  • 5,575
  • 13
  • 64
  • 113
24
votes
2 answers

What is wrong with this POST request implementation?

I have been working around Google OAuth 2.0 with java and got struck with some unknown error during implementation. The following CURL for POST request works fine: curl -v -k --header "Content-Type: application/x-www-form-urlencoded" --data…
vivek_jonam
  • 3,237
  • 8
  • 32
  • 44
23
votes
5 answers

Default timeout for HttpComponent Client

I can't find any documentation on the default httpParams for httpclient 4.1 ? What's the default socket timeout when I do a GET ?
thinkanotherone
  • 2,905
  • 9
  • 29
  • 37
17
votes
2 answers

Using Proxy with HttpComponentsClientHttpRequestFactory and RestTemplate

Can some one guide me how can I configure HttpComponentsClientHttpRequestFactory to use proxy server. All examples I have seen are using SimpleClientHttpRequestFactory.
16
votes
1 answer

PoolingHttpClientConnectionManager: How to do Https requests?

I'm currently trying to do multiple HttpGet requests at the same time with CloseableHttpClient. I googled on how to do that and the answer was to use a PoolingHttpClientConnectionManager. At this point I got this: PoolingHttpClientConnectionManager…
TorbenJ
  • 4,462
  • 11
  • 47
  • 84
1
2 3
36 37