apache-httpclient-4.x

Apache HTTPClient SSLPeerUnverifiedException

喜欢而已 提交于 2019-11-27 01:12:42
Using Apache HttpClient 4.2.1. Using code copied from the form based login example http://hc.apache.org/httpcomponents-client-ga/examples.html I get an exception when accessing an SSL protected login form: Getting library items from https://appserver.gtportalbase.com/agileBase/AppController.servlet?return=blank javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated Closing http connection at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:397) at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128) at org.apache.http.conn.ssl

RestTemplate vs Apache Http Client for production code in spring project

百般思念 提交于 2019-11-27 01:08:57
问题 we have a Spring project that is about to go into production. Currently, the project is using Apache Http Client . There is a thought of using RestTemplate as HttpClient . I am digging around to see any notable advantage of using RestTemplate over Apache's . Also, it would be interesting to know what HTTP transport does RestTemplate in its implementation. Apache Http Client has been used by several groups for many years and has a good reputation. would we be risking moving to RestTemplate ?

RestTemplate with Basic Auth in Spring 3.1

江枫思渺然 提交于 2019-11-27 00:57:56
问题 We were using RestTemplate with xml configuration in Spring 3.0 and it was working perfectly fine. <bean id="httpClient" class="org.apache.commons.httpclient.HttpClient"> <!-- <constructor-arg ref="httpClientParams"/> --> </bean> <bean id="httpClientFactory" class="org.springframework.http.client.CommonsClientHttpRequestFactory"> <constructor-arg ref="httpClient"/> </bean> <bean id="restTemplate" name="restTemplate" class="org.springframework.web.client.RestTemplate" autowire-candidate="true"

How do I save a file downloaded with HttpClient into a specific folder

若如初见. 提交于 2019-11-27 00:42:13
问题 I am trying to download a PDF file with HttpClient. I am able to get the file but i am not sure how to convert the bytes into a a PDF and store it somewhere on the system I have the following code, How can I store it as a PDF? public ???? getFile(String url) throws ClientProtocolException, IOException{ HttpGet httpget = new HttpGet(url); HttpResponse response = httpClient.execute(httpget); HttpEntity entity = response.getEntity(); if (entity != null) { long len = entity.getContentLength();

How to prevent apache http client from following a redirect

我只是一个虾纸丫 提交于 2019-11-27 00:19:49
I'm connecting to a remote server with apache http client. the remote server sends a redirect, and i want to achieve that my client isn't following the redirect automatically so that i can extract the propper header and do whatever i want with the target. i'm looking for a simple working code sample (copy paste) that stops the automatic redirect following behaviour . i found Preventing HttpClient 4 from following redirect , but it seems i'm too stupid to implement it with HttpClient 4.0 (GA) macbirdie The default HttpClient implementation is pretty limited in configurability, but you can

'org.apache.http.HttpEntity' is deprecated. How to solve this error in android studio?

你说的曾经没有我的故事 提交于 2019-11-26 22:55:13
问题 i'm using android studio API22 and i have these errors: 'org.apache.http.HttpEntity' is deprecated 'org.apache.http.HttpResponse' is deprecated 'org.apache.http.NameValuePair' is deprecated 'org.apache.http.client.HttpClient' is deprecated 'org.apache.http.client.entity.UrlEncodedFormEntity' is deprecated 'org.apache.http.client.methods.HttpPost' is deprecated 'org.apache.http.impl.client.DefaultHttpClient' is deprecated 'org.apache.http.message.BasicNameValuePair' is deprecated 'org.apache

Receiving Multipart Response on client side (ClosableHttpResponse)

穿精又带淫゛_ 提交于 2019-11-26 22:24:10
问题 I have a java controller which have to send me some text data and different byte arrays. So I am building n multipart request and writing it to stream from HttpServletResponse. Now my problem is how to parse the response at client side and extract the multiple parts. SERVER CODE SNIPPET:- MultipartEntityBuilder builder = MultipartEntityBuilder.create(); // Prepare payload builder.addBinaryBody("document1", file); builder.addBinaryBody("document2", file2); builder.addPart("stringData", new

HttpEntity is deprecated on Android now, what's the alternative?

*爱你&永不变心* 提交于 2019-11-26 22:10:23
With the release of Android 5.1, it looks like all the Apache http stuff has been deprecated. Looking at the documentation is useless; they all say This class was deprecated in API level 22. Please use openConnection() instead. Please visit this webpage for further details. Which is fine the first time you read it, but when EVERY class that was deprecated says that, it's not that helpful. Anyway, what are the alternatives for classes like HttpEntity , specifically StringEntity , and MultipartEntity ? I substituted BasicNameValuePair for my own implementation of Android's Pair<T, S> class, and

Apache HttpClient making multipart form post

天涯浪子 提交于 2019-11-26 21:29:54
I'm pretty green to HttpClient and I'm finding the lack of (and or blatantly incorrect) documentation extremely frustrating. I'm trying to implement the following post (listed below) with Apache Http Client, but have no idea how to actually do it. I'm going to bury myself in documentation for the next week, but perhaps more experienced HttpClient coders could get me an answer sooner. Post: Content-Type: multipart/form-data; boundary=---------------------------1294919323195 Content-Length: 502 -----------------------------1294919323195 Content-Disposition: form-data; name="number" 5555555555 --

Apache HttpClient GET with body

与世无争的帅哥 提交于 2019-11-26 20:54:53
问题 I am trying to send an HTTP GET with a json object in its body. Is there a way to set the body of an HttpClient HttpGet? I am looking for the equivalent of HttpPost#setEntity. 回答1: From what I know, you can't do this with the default HttpGet class that comes with the Apache library. However, you can subclass the HttpEntityEnclosingRequestBase entity and set the method to GET. I haven't tested this, but I think the following example might be what you're looking for: import org.apache.http