apache-httpclient-4.x

Apache Http Client slower than browser download

青春壹個敷衍的年華 提交于 2020-01-01 19:47:10
问题 I am downloading a large repository from github of size 300M. It takes 10-15sec when I download from my browser. On the same machine, it takes 110-120sec when I use below code to download. I am wondering if I am doing wrong. Please suggest me to get the same speed(10-15sec) using apache http client. Or is there anything better than http client ? Apache httpclient = 4.5 java - 8 Code that I used: import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL;

Retry java RestTemplate HTTP request if host offline

谁都会走 提交于 2020-01-01 01:48:38
问题 Hi I'm using the spring RestTemplate for calling a REST API. The API can be very slow or even offline. My application is building the cache by sending thousands of requests one after the other. The responses can be very slow too, because they contains a lot of data. I have already increased the Timeout to 120 seconds. My problem now it that the API can be offline and I get a org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool exception. In the case

Force retry on specific http status code

喜欢而已 提交于 2019-12-31 10:00:09
问题 Dealing with a specific website, sometimes I receive a http response with status code 403. I wanted to re-execute the request in such cases (because, in my specific situation, this server throws a 403 when it is actually overloaded). I tried to use a ResponseHandler together with a StandardHttpRequestRetryHandler , but it didn't work the way I hoped; I expected that throwing an exception in the ResponseHandler would trigger the StandardHttpRequestRetryHandler , but it does not seems to be the

What Java properties to pass to a Java app to authenticate with a http proxy

拈花ヽ惹草 提交于 2019-12-30 22:52:50
问题 I have a Java application that is trying to access a web service via http proxy. The Java app is 3rd party app for which we don't have access to source code. Its launch can be configured by passing Java launch parameters among other things. I am wondering what are the java properties that one can pass so that the app can use the logged in user's NTLM credentials to authenticate proxy connections? When I passed https.proxyHost and https.proxyPort (i.e. -Dhttps.proxyHost=abcd ... to jvm command

HttpClient won't import in Android Studio

限于喜欢 提交于 2019-12-27 09:01:36
问题 I have a simple class written in Android Studio: package com.mysite.myapp; import org.apache.http.client.HttpClient; public class Whatever { public void headBangingAgainstTheWallExample () { HttpClient client = new DefaultHttpClient(); } } and from this I get the following compile time error: Cannot resolve symbol HttpClient Isn't HttpClient included in the Android Studio SDK? Even if it is not, I added it to my Gradle build like this: dependencies { compile fileTree(dir: 'libs', include: ['*

HttpClient generates SSLException after acquiring new domain name

谁说我不能喝 提交于 2019-12-25 19:37:23
问题 Recently I acquired a new domain name to use with an existing Android application. I also bought SSL certificate from a trusted CA (Comodo). When I browse to the new domain with a web browser, everything works as expected - no errors about SSL certificate. Same with HttpUrlConnection , but for some reason Apaches HttpClient generates an SSLException: javax.net.ssl.SSLException: hostname in certificate didn't match: my.new.domain != my.old.domain OR my.old.domain What's more interesting, some

HttpClient from apache in Android?

耗尽温柔 提交于 2019-12-25 05:38:13
问题 I already have developed an desktop application using Java and now I need to develop the same application to Android. In my java application I've used the httpclient library from apache to make all http transactions, my question is: Can I use the same class HttpUtil that I've used in my java application with HttpClient in my new Android app ??? 回答1: Yes. Much, most, or all of your code can work in Android. Just make sure to continue using the Apache imports and not Google's (near) equivalents

Performance issues using neo4j rest http client

别来无恙 提交于 2019-12-25 03:57:20
问题 Struggling this after replacing neo4j-jdbc client with Apache http client. Seems like we still have issues when running only 1k concurrent users that execute our query. This is how we using the client: https://gist.github.com/IdanFridman/1989b600a0a032329a5e this is how we execute the query using that rest-client: https://gist.github.com/IdanFridman/22637f95ba696f498b6c after profiling we see the above bad performance results: With avg latency of 3 seconds per request. Should we ditch neo4j?

How do I upgrade from DefaultHttpClient() to HttpClientBuilder.create().build()?

烈酒焚心 提交于 2019-12-25 03:07:34
问题 I have a routine which checks if a record has been indexed by Solr. I have a deprecated method of creating a HTTPClient which I'm trying to remove: From DefaultHttpClient httpClient = new DefaultHttpClient(); To CloseableHttpClient httpClient = HttpClientBuilder.create().build(); The problem I now have is that after 2 call to the URL, the 3rd attempt seems to hang. I'm not quite sure what I'm missing if anyone can help please? This is my complete method which I've extracted out into a test:

Problems with HttpMethod.releaseConnection() and EntityUtils.consume(entity)

南笙酒味 提交于 2019-12-25 02:56:03
问题 I'm having a problem: I've just copied the following code from NetBeans to Eclipse (an ADT project). I've imported all the same librarys I used in NetBeans, but I have 2 errors, in the following lines: EntityUtils.consume(entity); - The method consume(HttpEntity) is undefined for the type EntityUtils httpPut.releaseConnection(); - The method releaseConnection() is undefined for the type HttpPut Complete code: import java.util.ArrayList; import java.util.List; import org.apache.http.HttpEntity