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
5
votes
2 answers

Why MultipartEntityBuilder throws org.apache.http.ContentTooLongException?

I have a simple Apache Camel route that gets the serialized files from the queue and sends it to some external resource: public class MyRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { …
user1134181
5
votes
1 answer

Mock Apache HTTPClient with ResponseHandler in Mockito

I've been trying to mock Apache HTTPClient with ResponseHandler, in order to test my service, using Mockito. The method in question is: String response = httpClient.execute(httpGet, responseHandler); where "responseHandler" is a…
Zmaja
  • 51
  • 4
5
votes
1 answer

HttpClient Connection pool shut down

I am using HttpClient v4.5.5 I have an HttpClient as below: PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(); connManager.setMaxTotal(totalMaxConnections); …
idipous
  • 2,868
  • 3
  • 30
  • 45
5
votes
1 answer

set number of retries with HttpAsyncClients

With the typical HttpAsyncClients example: public class AsyncClientHttpExchange { public static void main(final String[] args) throws Exception { CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault(); try { …
5
votes
2 answers

Cannot get 'location' header in response using HttpClient

The location header is there, I can see it in browser: I'm using org.apache.httpcomponents.httpclient to send http request with cookie: ``` URI uri = new…
Araell
  • 63
  • 1
  • 8
5
votes
1 answer

How can I send a body in a HTTP request using Apache http client's URIBuilder?

I know I can add http parameters using the setParameter method, but how do I pass a body to the http request using the URIBuilder class? For example, this URI uri = new URIBuilder().setScheme("http") …
gravetii
  • 9,273
  • 9
  • 56
  • 75
5
votes
1 answer

Recommended Set-Cookie Version used by web servers (0, 1, or 2)

I was running into some issues with cookie management using Apache HTTP Components as a client talking to a web application running on a Tomcat server. Long story short, I found that it was due to the Set-Cookie headers using version 0, which by…
Jared Gommels
  • 421
  • 6
  • 13
5
votes
3 answers

Unsupported record version SSLv2Hello using CloseableHttpClient

I am trying to make an https call and getting the following error: Unsupported record version SSLv2Hello Can anyone please shed some light on what I'm doing wrong? Thanks for your help. Here is the StackTrace: debug: Unsupported record version…
Mark Jones
  • 135
  • 1
  • 1
  • 10
5
votes
2 answers

Monitor download progress with apache http components

I have some big files to download with Apache's Http Components and I want to be able to display some progress info to users in the admin console of my web app. What is the right way to monitor a download in progress using this library? I will…
danb
  • 10,239
  • 14
  • 60
  • 76
5
votes
2 answers

how do i create and post a multipart/mixed http request using Apache HttpComponentst?

I am using Apache HttpComponents v4.3.3 (maven httpclient and httpmime). I need to upload a file with some metadata. The curl command, which works, looks like the following. curl -k -i -H "Content-Type: multipart/mixed" -X POST --form 'field1=val1'…
Jane Wayne
  • 8,205
  • 17
  • 75
  • 120
5
votes
3 answers

In httpclient what is the most elegant/correct way to turn HttpEntity to a String?

I'm fetching a web page using the Apache httpcomponents Java library. After connecting the result I get is an HttpEntity which has a method getContent() which returns an InputStream and also has a method writeTo() which writes to an OutputStream. I…
Nick Fortescue
  • 43,045
  • 26
  • 106
  • 134
5
votes
1 answer

httpcomponents's ssl connection results in socket is closed

I am trying to get some data from webserver which works fine with http. But when I try https(ssl connection), I get the exceptions like below. I get the http status code 200 and response content length 2230 which is correct. …
tompal18
  • 1,164
  • 2
  • 21
  • 39
5
votes
1 answer

Do I need to close expired connections in Apache HTTPAsyncClient?

Do I need to close expired connections in Apache HttpAsyncClient as is done with HttpClient?
VoodooChild
  • 400
  • 1
  • 6
  • 18
5
votes
0 answers

HttpGet.abort() / HttpPost.abort() doesn't always abort immediately

I'm using Apache HttpComponents 4.2.1 and I'm having trouble getting HttpGet.abort() and HttpPost.abort() to always abort immediately. It works most of the time, but occasionally the connection will block until it times out. I noticed this only…
dejuknow
  • 1,541
  • 2
  • 14
  • 30
5
votes
2 answers

How to set RequestBody for Http Delete method.

I am writing a client code for a server which Delete API. The API specification requires data to be sent. I am using HttpComponents v3.1 library for writing client code. Using the HtpDelete class I could not find a way to add request data to it. Is…
Tushar Tarkas
  • 1,592
  • 13
  • 25