apache-httpclient-4.x

Java8, HttpClient, receiving “Received fatal alert: handshake_failure”

余生长醉 提交于 2019-12-05 03:00:54
We're trying to access the following URL (just an example) https://broadly.vice.com/en_us/article/eating-out-as-a-feminist but we're receiving "Received fatal alert: handshake_failure". We're using JDK 1.8.60, HttpClient 4.3.6 and already replaced the jce-policy to the unlimited policy. After activating -Djavax.net.debug=all we receive: Allow unsafe renegotiation: false Allow legacy hello messages: true Is initial handshake: true Is secure renegotiation: false Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 for TLSv1 Ignoring unsupported cipher suite: TLS_ECDHE_RSA

Should I still set ConnectionRequestTimeout on Apache HttpClient if I don't use a custom connection manager?

白昼怎懂夜的黑 提交于 2019-12-05 02:59:09
I am using Apache RequestConfig to configure some timeouts on my HttpClient . RequestConfig config = RequestConfig.custom() .setConnectTimeout(timeout) .setSocketTimeout(timeout) .setConnectionRequestTimeout(timeout) // Can I leave this out.. .build(); CloseableHttpClient httpClient = HttpClients.custom() //.setConnectionManager(connectionManager) // ..if I don't use this .setDefaultRequestConfig(config) .build(); Does it make any sense to call setConnectionRequestTimeout(timeout) even I don't have a custom Connection Manager / Pool set up? As far as I understand, setConnectionRequestTimeout

Java, Apache HttpClient, TLSv1.2 & OpenJDK 7

心已入冬 提交于 2019-12-05 02:14:25
问题 We have a small group of Tomcat servers running OpenJDK v1.7.0_111. We have plans to upgrade them and migrate them this summer but we've found that a client API we interact with is moving to require TLSv1.2 in the near term. My ultimate desire is to find a configuration change to allow for this. The application hosted there creates it's SSL context in a pretty straight forward way: SSLContext sslContext = SSLContexts.createDefault() SSLConnectionSocketFactory sslsf = new

HttpPost with StringEntity having special characters like ®, seeing ¿½` instead of ®

☆樱花仙子☆ 提交于 2019-12-05 01:06:36
I need to use special characters for stringentity as below. DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); HttpEntity entity = new StringEntity("test®"); httpPost.setEntity(entity); httpPost.setHeader("Accept-Encoding", "UTF-8"); HttpResponse response = httpClient.execute(httpPost); BufferedReader reader = new BufferedReader(new InputStreamReader((response.getEntity().getContent()))); while ((reader.readLine()) != null) { System.out.println (reader.readLine()); } reader.close(); The output contains test� instead of test® in the response. Change

Migrating from HttpClient 3.x to 4.x

别等时光非礼了梦想. 提交于 2019-12-04 23:52:40
We have some code written using commons-httpclient-3.1 that needs to be converted to 4.1. I'm only somewhat familiar with this and am reading the 4.1 httpclient tutorial now. I see a couple of posts here (e.g. Converting from HttpClient 3 to 4 but that's about a specific construct). Seems like there should be some docs/examples somewhere showing how to upgrade usage of 3.x to 4.x ? One specific example: replacing use of org.apache.commons.httpclient.HttpState I would replace the library jar(s) in your IDE and look for compiler errors to start with. You may wish to go back and check all usages

Apache HttpClient use own SSL-certificates

拈花ヽ惹草 提交于 2019-12-04 19:32:14
I am trying to connect to a https secured restwebservice using httpclient 4.0.3 with Java7. My code looks like this: public static void main(String[] args) throws Exception { ClientRequest req = new ClientRequest("https://127.0.0.16:8443/rest/lstgs/create", new ApacheHttpClient4Executor(doSSLBlackMagic())); // ... random stuff that has nothing to do with SSL ClientResponse<String> response = req.post(String.class); if (response.getStatus() != 201) { throw new RuntimeException("error, status: " + response.getStatus() + " / " + response.getEntity()); } else { System.out.println(response

How to create a Folder with Google Drive REST AP and HTTPClient?

北战南征 提交于 2019-12-04 18:54:08
I am using Google Drive REST API with HTTPClient to create a folder. The REST API is document here Please note that the REST AP Request executes -- but uses the wrong data: tt creates a new file called "untitled" and puts my json there. I have tried different methods of building the POST request with HTTPClient which execute successfully -- but somehow the Google Drive responds with creating a file and returns this data and ignores POST data that I submit. This is what the server reponds with .. "kind": "drive#file", "id": "0B-fYJN-c4UDjUlh1TUZadF9vejA", this is a valid ID "title": "Untitled",

Peer not authenticated in java

白昼怎懂夜的黑 提交于 2019-12-04 18:38:00
I have gone to almost all the post related to this exception. Actually my problem is I have an java application through which I am hitting an URL and getting response from it. code to hit URL is : HttpGet getRequest = new HttpGet("https://urlto.esb.com"); HttpResponse httpResponse = null; DefaultHttpClient httpClient = new DefaultHttpClient(); httpResponse = httpClient.execute(getRequest); Here I am getting javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated So after some Google search I come to know that I can import certificate in keystore of java where the application is

Apache Http Client slower than browser download

こ雲淡風輕ζ 提交于 2019-12-04 18:22:26
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; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.http

setConnectTimeout vs. setConnectionTimeToLive vs. setSocketTimeout()

不打扰是莪最后的温柔 提交于 2019-12-04 17:49:55
问题 can someone please explain what is the difference between these two: client = HttpClientBuilder.create() .setConnectionTimeToLive(1, TimeUnit.MINUTES) .build(); and RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(30 * 1000).build(); client = HttpClientBuilder .create() .setDefaultRequestConfig(requestConfig) .build(); Is it better to use setSocketTimeout ? 回答1: A ConnectTimeout determines the maximum time to wait for the other side to answer "yes, I'm here, let's talk"