apache-httpclient-4.x

Invalid use of BasicClientConnManager: connection still allocated

感情迁移 提交于 2019-12-03 18:32:53
问题 I am making a call to REST URL and trying to measure how much time it is taking to get the response back. I am using DefaultHttpClient for that to get the response back from REST URL . In my below program , each thread will be working on a particular range. Like Each Thread will work between 1 - 100 and second thread will work between 101 - 200 etc. SO in my below code, for the first time it works fine. But for the second time, it is throwing exception on this line httpclient.execute for the

What is SchemeRegistry in apache and When it should be used?

南笙酒味 提交于 2019-12-03 16:18:36
Apache HTTPClient contains SchemeRegistry class (org.apache.http.conn.scheme.SchemeRegistry) What is Scheme Registry? When can it be used? What impact does it make if i use scheme registry like below SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme(WEBSERVICE_URI_SCHEME, 80 ,PlainSocketFactory.getSocketFactory())); PoolingClientConnectionManager wsConnManager = new PoolingClientConnectionManager (registry); What is Scheme Registry? Protocol scheme registry maintains a map of connection socket factories per distinct protocol scheme. For instance, HTTPS scheme

Android 6.0 HTTPClient issue with LG G3 phone

匆匆过客 提交于 2019-12-03 15:20:04
问题 Hi I am using DefaultHTTPClient class to create http request. The currrent code execute() method works on all phones including Nexus and Samsung with Android 6.0. But when i tested on LG phones with Android 6.0 update, i am getting error as shown below Java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 03-28 17:21:17.040: E/xx_SDK(14035): at org.apache.http.impl.auth.DigestScheme.isGbaScheme(DigestScheme.java:210) 03-28 17:21:17.040: E/xx_SDK(14035): at org.apache.http.impl.auth

Apache HttpClient and PEM certificate files

帅比萌擦擦* 提交于 2019-12-03 13:15:41
问题 I'd like to programmatically access a site that requires Client certificates, which I have in PEM files. In this application I don't want to add them to my keystore, use keytool, or openssl if I can avoid doing so. I need to deal with them directly in code. HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("https://my.secure.site.com/url"); // TODO: Specify ca.pem and client.pem here? HttpResponse response = httpclient.execute(httpget); HttpEntity entity =

setConnectTimeout vs. setConnectionTimeToLive vs. setSocketTimeout()

北城以北 提交于 2019-12-03 11:33:11
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 ? A ConnectTimeout determines the maximum time to wait for the other side to answer "yes, I'm here, let's talk" when creating a new connection ( ConnectTimeout eventually calls socket.connect(address, timeout) . The wait

NoSuchFieldError INSTANCE at org.apache.http.impl.io.DefaultHttpRequestWriterFactory

▼魔方 西西 提交于 2019-12-03 09:56:41
java version "1.7.0_71" Gradle 2.1 Hello, UPDATE: The dependencies gradle dependencies | grep httpcore | +--- org.apache.httpcomponents:httpcore:4.3.3 | +--- org.apache.httpcomponents:httpcore:4.3.3 | +--- org.apache.httpcomponents:httpcore:4.3.3 | +--- org.apache.httpcomponents:httpcore:4.3.3 | | | | | +--- org.apache.httpcomponents:httpcore:4.1 -> 4.3.3 | +--- org.apache.httpcomponents:httpcore:4.3.3 | | | | | +--- org.apache.httpcomponents:httpcore:4.1 -> 4.3.3 Does this mean I have 4.1 that is a soft link to 4.3.3? Seems strange as when I print out what the class loader is loading it seems

Digest auth with Java & Apache client : Always 401 Unauthorized

梦想的初衷 提交于 2019-12-03 08:31:58
I'm trying to implement digest auth with an HTTP client, but this does not work at the moment. Can someone check if this code is correct? For testing purpose I use http://httpbin.org/ , but all I get is HTTP/1.1 401 Unauthorized . Here is the example code: private static void doDigestAuth() throws ClientProtocolException, IOException, AuthenticationException, MalformedChallengeException { HttpHost target = new HttpHost("httpbin.org", 80, "http"); CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(target.getHostName(), target.getPort()

How do I set SSL protocol version in java? And how do I know which one? javax.net.ssl.SSLException: Received fatal alert: protocol_version

主宰稳场 提交于 2019-12-03 08:00:32
问题 I am using Apache HttpClient 4.3 to interact with the API of hubic.com. My minimal reproducable example is just a one liner: HttpClientBuilder.create().build().execute(new HttpGet("https://hubic.com")); However that throws: Exception in thread "main" javax.net.ssl.SSLException: Received fatal alert: protocol_version at sun.security.ssl.Alerts.getSSLException(Alerts.java:208) at sun.security.ssl.Alerts.getSSLException(Alerts.java:154) at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl

sending post data to https without ssl cert verification with apache httpClient client

夙愿已清 提交于 2019-12-03 07:54:38
问题 I need to send post data to an https url using the apache HttpClient package, after sending the post data I need to retreive the html data. the post data that I'm sending is an XML string and the post data that I'm receving is an XML string. any information regarding the issue would be greatly appreciated. I googled and i found examples on the internet that uses DefaultHttpClient that now in version 4 is deprecated. so I'd like to know how to properly use the new version of the client. thanks

javax.net.ssl.SSLPeerUnverifiedException: No peer certificate while I am working with google place api in android [duplicate]

天大地大妈咪最大 提交于 2019-12-03 06:54:35
This question already has answers here : Android: Making Https Request (2 answers) I am facing an javax.net.ssl.SSLPeerUnverifiedException: No peer certificate exception while working with google place api in android emulator.Below is my url: https://maps.googleapis.com/maps/api/place/search/json?&location=28.632808,77.218276&radius=1000&sensor=false&key=AIzaSyC3y3fOMTqTkCjNNETQTCKustG7BRk_eVc when i simply , paste above url in browser address bar , it simple gives Json string.So , i think there is no need of any certificate authentication. After doing so many googling and devoted 2-3 days, i