apache-commons-httpclient

How do Jersey-client and Apache HTTP Client compare?

安稳与你 提交于 2019-12-18 09:56:30
问题 First of all, I'm not trying to start a flame-war here. I know Jersey sufficiently well, but have hardly used httpclient. What are the key differences between jersey-client and Apache's httpclient? In what areas is one better than the other? Is there a good comparison chart somewhere? Which one performs better with larger files (say 2048 MB)? Many thanks for your comments! 回答1: These two things probably should not be compared directly. Jersey is a REST-client, featuring full JAX-RS

Basic Authentication using HTTP Commons Client

会有一股神秘感。 提交于 2019-12-18 08:31:09
问题 I am looking at this link an am trying to send requests to the server http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html public class Test { public static void main(String[] args) throws ClientProtocolException, IOException { DefaultHttpClient httpClient; URL url = new URL("https://9.5.127.34:443"); httpClient = getSSLHttpClient(url); CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials( new AuthScope("https://9.5.127.34

Basic Authentication using HTTP Commons Client

大兔子大兔子 提交于 2019-12-18 08:31:03
问题 I am looking at this link an am trying to send requests to the server http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html public class Test { public static void main(String[] args) throws ClientProtocolException, IOException { DefaultHttpClient httpClient; URL url = new URL("https://9.5.127.34:443"); httpClient = getSSLHttpClient(url); CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials( new AuthScope("https://9.5.127.34

How to handle invalid SSL certificate with Apache client 4.5.5?

£可爱£侵袭症+ 提交于 2019-12-18 07:21:43
问题 I am trying to use Apache Client 4.5.5 to connect to one of my web server. I am trying to use SSLContextBuilder but it seems its deprecated now, I don't want to use deprecated. Can someone suggest what are the latest way to handle Invalid certification? Below is my code it works fine but SSLContext, SSLContextBuilder, loadTrustmaterial are deprecated. SSLContextBuilder sscb = new SSLContextBuilder(); sscb.loadTrustMaterial(null, new org.apache.http.conn.ssl.TrustSelfSignedStrategy());

How to stream response body with apache HttpClient

社会主义新天地 提交于 2019-12-18 03:39:02
问题 There's an api I need to perform octet-streaming from which does not have a length. It is just a stream of real time data. The issue that I'm having is that when I make my request, it seems to try to wait out for the end of the content before reading information into the inputstream, however it's not seeing the end of the content and timingout with NoHttpResponse exception. Below is a simplified version of my code: private static HttpPost getPostRequest() { // Build uri URI uri = new

How can I disable default request headers from apache httpclient 4?

被刻印的时光 ゝ 提交于 2019-12-18 02:42:04
问题 I am using apache common httpclient 4.3.3 to make http 1.0 request. Here is how I make the request HttpClient client = HttpClientBuilder.create().build(); HttpPost post = new HttpPost(url); post.setProtocolVersion(new ProtocolVersion("HTTP", 1, 0)); // trying to remove default headers but it doesn't work post.removeHeaders("User-Agent"); post.removeHeaders("Accept-Encoding"); post.removeHeaders("Connection"); post.setEntity(new ByteArrayEntity(ba) ); HttpResponse response = client.execute

Apache HttpClient 4.1 - Proxy Settings

狂风中的少年 提交于 2019-12-17 22:31:23
问题 I am trying to POST some parameters to a server, but I need to set up the proxy. can you help me to to sort it "setting the proxy" part of my code ? HttpHost proxy = new HttpHost("xx.x.x.xx"); DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter("3128",proxy); HttpPost httpost = new HttpPost(url); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("aranan", song)); httpost.setEntity(new UrlEncodedFormEntity(nvps,

Apache HttpClient 4 And JavaScript

断了今生、忘了曾经 提交于 2019-12-17 16:39:42
问题 I Use Apache HttpClient to Access a webpage . i want to click on a link but the link is javaScript , how can i process click on a javascript link and follow url redirection ? sample javascript and html code : <a href="javascript:send(32023, 'YGHN_JKM', '8LMK');"> link</a> function send(content_id, fic, cgRate) { var params = new Hash(); params.set('content_id', content_id); params.set('tool', fic); params.set('cgRate', cgRate); new Ajax.Updater('return', '/mypkg/tools', { method: 'post',

How to force Commons HTTPClient 3.1 to use TLS 1.2 only for HTTPS?

冷暖自知 提交于 2019-12-17 10:47:29
问题 I wish to force Apache Commons HTTP-Client (version 3.1 ) to use TLS 1.2 as the only protocol for HTTPS. This is due to the server supposedly being upgraded to TLS 1.2 and not accepting any older protocol anymore (causing 'Connection Reset' to be returned). For further context, probably irrelevant, the HTTP-Client is used along with Axis2 to make a SOAP; some of the code used for setting up the HttpClient is below: MultiThreadedHttpConnectionManager connMgr = new

Does Apache Commons HttpClient support GZIP?

こ雲淡風輕ζ 提交于 2019-12-17 09:38:18
问题 Does the library Apache Commons HttpClient support Gzip? We wanted to use enable gzip compression on our Apache server to speed up the client/server communications (we have a php page that allows our Android application to sync files with the Server). 回答1: Apache HttpClient 4.1 supports content compression out of the box along with many other features that were previously considered out of scope. 回答2: If your server is able to provide GZIPped content, with Apache Http client 4.1 all you need