apache-httpcomponents

maven dependency pulling a wrong dependency

夙愿已清 提交于 2019-11-29 13:56:44
I have a dependency as follows: <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.2</version> <scope>compile</scope> </dependency> This is pulling down another dependency httpcore.4.1.4 which throws a ClassDefNotFound, when i deploy httpcore.4.2 everything works. I added both of the dependencies as follows: <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.2</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore<

Signing AWS HTTP requests with Apache HttpComponents Client

99封情书 提交于 2019-11-29 06:17:43
I'm trying to make HTTP requests to an AWS Elasticsearch domain protected by an IAM access policy. I need to sign these requests for them to be authorized by AWS. I'm using Jest , which in turn use Apache HttpComponents Client . This seems to be a common use case and I was wondering if there is out there some kind of library which I can use on top of Apache HttpComponents Client to sign all the requests. I think I found it! :) This project seems to do exactly what I want : aws-signing-request-interceptor , described as "Request Interceptor for Apache Client that signs the request for AWS.

PoolingHttpClientConnectionManager: How to do Https requests?

余生长醉 提交于 2019-11-28 17:57:59
问题 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 cManager = new PoolingHttpClientConnectionManager(); CloseableHttpClient httpClient = HttpClients.custom() .setConnectionManager(cManager) .build(); Then I tried a HttpGet request to http://www.google.com and everything worked fine. Then I

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

和自甴很熟 提交于 2019-11-28 17:04:37
问题 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 GsonHttpMessageConverter())); Result result = restTemplate.postForObject(url, payload, Result.class); When I make a lot of these requests, I am getting the following exception: Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST

Apache HttpComponents HttpClient timeout

試著忘記壹切 提交于 2019-11-28 15:47:13
问题 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 explanation of the difference between SO_TIMEOUT and CONNECTION_TIMEOUT would be helpful. 回答1: In version 4.3 of Apache Http Client the configuration was refactored (again). The new way looks like this: RequestConfig.Builder requestBuilder =

Mockito when() doesn't differentiate between child classes

浪尽此生 提交于 2019-11-28 14:23:24
I wrote a test that uses Mockito 1.9.5. I have an HttpGet and an HttpPost which an HttpClient execute, and I'm testing to verify that the response from each returns the expected result in the form of an input stream. The issue is that while using Mockito.when(mockedClient.execute(any(HttpPost.class))).thenReturn(postResponse) and Mockito.when(mockedClient.execute(any(HttpGet.class))).thenReturn(getResponse) , where the responses are different objects, mockedClient.execute() always returns getResponse . The test I've written is below: private InputStream postContent; private InputStream

Error while trying to use an API. java.lang.NoSuchFieldError: INSTANCE

旧时模样 提交于 2019-11-28 12:09:47
I am trying to connect to the smartsheet api using a java program. Initially I had problems with the site certificate which was resolved by adding it to the java keystore. Now when I am trying to run my code, I get the following error. Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144) at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:955) at org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58) at com.smartsheet.api.internal.http

Apache HttpClient Android (Gradle)

五迷三道 提交于 2019-11-27 17:35:34
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 anyone help me with this? if you are using target sdk as 23 add below code in your build.gradle android{ useLibrary 'org.apache.http.legacy' } additional note here: dont try using the gradle versions of those files. they are broken (28.08.15). I tried over 5 hours to get it to work. it just doesnt. not working: compile 'org.apache.httpcomponents

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

六眼飞鱼酱① 提交于 2019-11-26 23:23:23
I 've met such error when I use Android studio 3.1 to build an Android P 's app, the apk can be made ,but when I use it on Android P emulator , it will crash and throw below info, more details see the pic. java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion part of my build.gradle under App module is below , anybody meet this ?And give some suggesstion ? Many thanks. android { compileSdkVersion 'android-P' buildToolsVersion '28-rc1' useLibrary 'org.apache.http.legacy' //for Lambda compileOptions { targetCompatibility JavaVersion.VERSION_1_8 sourceCompatibility

Apache HttpClient Android (Gradle)

此生再无相见时 提交于 2019-11-26 22:35:09
问题 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 anyone help me with this? 回答1: if you are using target sdk as 23 add below code in your build.gradle android{ useLibrary 'org.apache.http.legacy' } additional note here: dont try using the gradle versions of those files. they are broken (28.08.15).