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
6
votes
1 answer

Java- apache http client- usage examples showing use of cookies and extracting response from HTTPResponse object

I am working with apache http client (v4) in a java web app, and I am stuck in the following cases, for which I require simple usage examples-- (1) How to use Cookies with Apache HTTP client, different options available for usage of cookies (2)…
Arvind
  • 6,404
  • 20
  • 94
  • 143
6
votes
3 answers

Apache Http Client - Stop Removing Double Slashes from URL

I am using Apache HTTP Components Client 4.5.7 to request a URL that containing a double slash. When I look at the wire log, I see that the double slash was "fixed" to be only one slash. Unfortunately that is no desireable behaviour for me, as it…
Matthias
  • 2,622
  • 1
  • 18
  • 29
6
votes
1 answer

Disable redirect for specific requests with the same client using HttpClient

I would like to know how I can disable redirect for specific requests when using HttpClient. Right now, my client either allows or disables redirects for all its request. I want to be able to make some requests with redirects but some with redirect…
birgersp
  • 3,909
  • 8
  • 39
  • 79
6
votes
2 answers

How to create Spring WebClient from Apache Http Client

I want to create WebClient from HttpComponent's org.apache.http.client.HttpClient to use it in async operations.Any idea on how to do it
6
votes
1 answer

java.lang.InterruptedException while executing Apache HttpClient

We use the library org.apache.http.client.HttpClient in accessing other web services from our web services. HttpRequestBase requestBase = httpClient.execute(requestBase); Now at certain times, this exception happens: * Caused by:…
6
votes
1 answer

How to enable SSLv3 with Apache HttpClient?

SSLv3 is disabled in Apache HttpClient since version 4.3.6, but I'm using version 4.5. The developers wrote: Those users who wish to continue using SSLv3 need to explicitly enable support for it. I tried to set the supported protocols on the JVM…
deamon
  • 89,107
  • 111
  • 320
  • 448
6
votes
3 answers

Handling downloads in Java

How would I be able to handle downloads using HttpResponse in Java? I made an HttpGet request to a specific site - the site returns the file to be downloaded. How can I handle this download? InputStream doesn't seem to be able to handle it (or maybe…
Tereno
  • 923
  • 1
  • 13
  • 20
6
votes
1 answer

Change HttpClients HTTP version to HTTP/1.0

im trying to use HTTP/1.0 with Apache HttpClient 4.3, but I can't find out how. In 3.x version it was done this way: httpClient.getParams().setParameter("http.protocol.version", HttpVersion.HTTP_1_0); Thats deprecated by now. How to do it now?…
JuSch
  • 73
  • 1
  • 3
6
votes
2 answers

Importing a newer Apache HttpClient jar in Android

I'm trying to send an HTTP/HTTPS post request from my Android client. Question Why does my code fail? So far I created an apache class/HttpClient call. Everything worked fine: HttpClient httpClient = new DefaultHttpClient(); I've read that this…
Jjang
  • 11,250
  • 11
  • 51
  • 87
6
votes
3 answers

Apache HttpClient response content length returns -1

Why does the following Code returns -1? Seems that the request failed. public static void main(String[] args) { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet("http://www.google.de"); HttpResponse…
PeterMoron
  • 93
  • 1
  • 1
  • 3
6
votes
1 answer

Getting java.lang.NoClassDefFoundError while using Google Gson library

I am using Gson library to convert objects to Json and vice versa. I have copied the jars of that library into a new folder lib and added it to the build path for the project in my Eclipse IDE. I have one main class where I convert an object into…
Rajath
  • 2,178
  • 6
  • 32
  • 38
6
votes
1 answer

HttpComponents Custom SSLSocketFactory

Per the example at http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientCustomSSL.java SSLSocketFactory socketFactory = new SSLSocketFactory(trustStore); Should instantiate a SSLSocketFactory using…
ItinerantEngineer
  • 255
  • 1
  • 4
  • 14
5
votes
1 answer

HTTP authentication with Apache HTTP Components: force sending of challenge

I need to talk to an obscure webserver which requires authentication. If I don't supply credentials, a login form is displayed. However, if I do supply unsolicited Basic Authentication credentials, I get directly to the desired content. wget…
Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084
5
votes
3 answers

Java HttpClient seems to be caching content

I'm building a simple web-scraper and i need to fetch the same page a few hundred times, and there's an attribute in the page that is dynamic and should change at each request. I've built a multithreaded HttpClient based class to process the…
Trota
  • 145
  • 3
  • 9
5
votes
2 answers

What is the equivalence of SSLKEYLOGFILE in a Java program?

Where is SSLKEYLOGFILE defined? As discussed above, SSLKEYLOGFILE can be used with some program to capture the key log. But Java programs using TLS do not respect this environment variable. What is the correct way to let such a Java program dump the…
user1424739
  • 11,937
  • 17
  • 63
  • 152