apache-httpcomponents

“ConnectionPoolTimeoutException” when iterating objects in S3

99封情书 提交于 2019-12-03 02:05:56
I've been working for some time with aws java API with not so many problems. Currently I'm using the library 1.5.2 version. When I'm iterating the objects inside a folder with the following code: AmazonS3 s3 = new AmazonS3Client(new PropertiesCredentials(MyClass.class.getResourceAsStream("AwsCredentials.properties"))); String s3Key = "folder1/folder2"; String bucketName = Constantes.S3_BUCKET; String key = s3Key +"/input_chopped/"; ObjectListing current = s3.listObjects(new ListObjectsRequest() .withBucketName(bucketName) .withPrefix(key)); boolean siguiente = true; while (siguiente) {

HttpComponents PoolingHttpClientConnectionManager maxPerRoute and maxTotal?

随声附和 提交于 2019-12-03 01:26:42
Can someone please explain to me what setMaxPerRoute(max) and setMaxTotal(max) do in reference to HttpComponents PoolingHttpClientConnectionManager? These settings control connection pool size. setMaxTotal(max) defines the overal connection limit for a conneciton pool. setMaxPerRoute(max) defines a connection limit per one HTTP route. In simple cases you can understand this as a per target host limit. Under the hood things are a bit more interesting: HttpClient maintains a couple of HttpRoute objects, which represent a chain of hosts each, like proxy1 -> proxy2 -> targetHost . Connections are

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

我的未来我决定 提交于 2019-12-03 01:00:29
问题 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 all GET requests? public String myMVCControllerGETdataMethod() { // Send 1st request HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://api/data?type=1"); ResponseHandler<String> responseHandler = new

Force retry on specific http status code

给你一囗甜甜゛ 提交于 2019-12-02 19:38:11
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 case. How can I achieve the desired functionality? Here is a sample code that illustrates my situation

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

浪子不回头ぞ 提交于 2019-12-02 16:11:48
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 of how to do this? Thanks a lot. We do basic authentication with HttpClient , but we do not use CredentialProvider . Here's the code: HttpClient client = factory.getHttpClient(); //or any method to get a client instance Credentials credentials = new UsernamePasswordCredentials(username, password); client.getState().setCredentials(AuthScope.ANY,

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

陌路散爱 提交于 2019-12-02 14:19:19
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 all GET requests? public String myMVCControllerGETdataMethod() { // Send 1st request HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://api/data?type=1"); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httpget, responseHandler); // Send 2st request

Apache HttpComponents: org.apache.http.client.ClientProtocolException

巧了我就是萌 提交于 2019-12-02 05:43:46
问题 So I use apache HttpComponents to handle http request in java. Now I want to reuse the DefaultHttpClient , what should be possible accoarding to this example: http://wiki.apache.org/HttpComponents/QuickStart. The example itselfs give a ssl error so I modefied and simplefied it a bit. Now I always get a org.apache.http.client.ClientProtocolException Here is my example program, basicly I just request 2 webpages using the same DefaultHttpClient . import java.io.ByteArrayOutputStream; import java

Access all entries of HttpParams

牧云@^-^@ 提交于 2019-12-02 01:06:52
问题 Is there a way of iterating over all entries of an HttpParams object? Someone else had a similar problem ( Print contents of HttpParams / HttpUriRequest? ) but the answers don't really work. When looking into BasicHttpParams I see that there is a HashMap inside, but no way of accessing it directly. Also AbstractHttpParams doesn't provide any direct access to all entries. Since I cannot rely on predefined key names the ideal way would be to iterate just over all entries HttpParams encapsulates

Access all entries of HttpParams

我怕爱的太早我们不能终老 提交于 2019-12-01 23:07:58
Is there a way of iterating over all entries of an HttpParams object? Someone else had a similar problem ( Print contents of HttpParams / HttpUriRequest? ) but the answers don't really work. When looking into BasicHttpParams I see that there is a HashMap inside, but no way of accessing it directly. Also AbstractHttpParams doesn't provide any direct access to all entries. Since I cannot rely on predefined key names the ideal way would be to iterate just over all entries HttpParams encapsulates. Or at least get a list of key names. What am I missing? Your HttpParams is used to create HttpEntity

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

余生长醉 提交于 2019-12-01 19:23:27
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 line), I do see difference in the logs. Now it fails with message below. [WrapperSimpleAppMain]