apache-httpclient-4.x

RestEasy Client Authentication and HTTP Put with Marshalling

♀尐吖头ヾ 提交于 2019-12-05 19:27:13
I want to test my REST-Service using the RestEasy Client Framework. In my application I am using Basic Authentication. According to the RestEasy documentation I am using the org.apache.http.impl.client.DefaultHttpClient to set the Credentials for Authentication. For an HTTP-GET Request this works fine, I am authorized and I get the result Response which I wanted. But what if I want to make a HTTP-Post/HTTP-Put with an Java Object (in XML) in the HTTP-Body of the Request? Is there a way to automatically marshall the Java Object into the HTTP-Body when I am using the org.apache.http.impl.client

How to use HttpAsyncClient with multithreaded operation?

杀马特。学长 韩版系。学妹 提交于 2019-12-05 19:15:25
Closely related to this question: How to use HttpClient with multithreaded operation? , I'm wondering if apache HttpAsyncClient is thread safe, or if it, too, requires the use of a MultiThreadedHttpConnectionManager, or a ThreadSafeClientConnManager. If it does require such a connection manager, does one exist in the async libraries? I was able to find a PoolingClientAsyncConnectionManager in the async libraries, but I'm not sure if that's what I need. Alternately, I was thinking of using ThreadLocal to create one HttpAsyncClient object per thread. Note that unlike the question I referenced

HttpRoutePlanner - How does it work with an HTTPS Proxy

て烟熏妆下的殇ゞ 提交于 2019-12-05 12:24:19
I have an HTTPS proxy set up so that HTTP clients can send plain HTTP requests securely to the proxy. For example, a client can send an encrypted HTTP GET request to the proxy, which will remove the encryption and send the plain HTTP GET request to the end-site. I learned that this is not a common set up and only Google Chrome has in-built features to support such a scenario. (Info here - http://wiki.squid-cache.org/Features/HTTPS#Encrypted_browser-Squid_connection ). I have made Google Chrome work with my HTTPS proxy and hence there is no trouble on the proxy side. I wish to write an HTTP

set nonProxyHosts in Apache HttpClient 4.1.3

北城以北 提交于 2019-12-05 10:21:31
I just cant help myself by answering this question. How can I set nonProxyHosts in the Apache HttpClient 4.1.3? In the old Httpclient 3.x that was quite simple. U could just set it using the setNonProxyHosts methods. But now, there's no equivalent method for the new version. I have been looking trough the api docs, tutorials and examples and havent found the solution so far. to set a normal proxy u can just do it by this: HttpHost proxy = new HttpHost("127.0.0.1", 8080, "http"); DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT

For a HttpGet method what are getParams()?

依然范特西╮ 提交于 2019-12-05 10:17:43
org.apache.http.client.methods.HttpGet; HttpGet method = new HttpGet(url.toExternalForm()); method.getParams() Whare are these params? Are they the query string? there seems to be no easy way to add a query string with org.apache.http.client.methods.HttpGet Michael Borgwardt According to the Http Client tutorial , you can do this: URI uri = new URIBuilder() .setScheme("http") .setHost("www.google.com") .setPath("/search") .setParameter("q", "httpclient") .setParameter("btnG", "Google Search") .setParameter("aq", "f") .setParameter("oq", "") .build(); HttpGet httpget = new HttpGet(uri); System

HttpClient 4.2, Basic Authentication, and AuthScope

心不动则不痛 提交于 2019-12-05 09:10:55
I have an application connecting to sites that require basic authentication. The sites are provided at run time and not known at compile time. I am using HttpClient 4.2. I am not sure if the code below is how I am supposed to specify basic authentication, but the documentation would suggest it is. However, I don't know what to pass in the constructor of AuthScope . I had thought that a null parameter meant that the credentials supplied should be used for all URLs, but it throws a NullPointerException , so clearly I am wrong. m_client = new DefaultHttpClient(); UsernamePasswordCredentials

Handshake fail on Lollipop

谁都会走 提交于 2019-12-05 07:00:35
问题 I'm trying to do a HTTP POST but I get two different errors: javax.net.ssl.SSLHandshakeException: Handshake failed net.ssl.SSLPeerUnverifiedException: No peer certificate I fixed the No peer certificate error through a workaround as specified here: https://stackoverflow.com/a/4837230/4254419 but while that fixes the error, it throws a new error instead, which is Handshake failed I know it's not safe and I don't care, it's not for production so I care less about security. Is there a fix for

Android JAVA to SharePoint 2013 NTLM 401 Unauthorize

丶灬走出姿态 提交于 2019-12-05 04:43:33
问题 I'm new to Java. Cause my company require to create an App for SharePoint 2013. I keep on get error 401. I have search through a lot of website and i just couldn't get it work. The code I'm using as per below: StringBuilder sb = new StringBuilder(); SSLContext sslContext = null; // Error Handling try { sslContext = SSLContext.getInstance("SSL"); sslContext.init(null, new TrustManager[]{new X509TrustManager() { @Override public void checkClientTrusted(X509Certificate[] chain, String authType)

Include Http-4.2.1 with Android App

烈酒焚心 提交于 2019-12-05 04:35:56
问题 I wish to include the latest version of Http with my Android App, which is 4.2.1. Now wish to download the library from Apache website and include it in the libs folder and then to the build path of my app. On including Http - 4.2.1, I got the following output in the logcat 08-28 02:42:40.917: D/dalvikvm(25641): DexOpt: 'Lorg/apache/http/client/ResponseHandler;' has an earlier definition; blocking out 08-28 02:42:40.917: D/dalvikvm(25641): DexOpt: 'Lorg/apache/commons/codec/Decoder;' has an

Enable debug logging for Log4J2 + Apache HttpClient

廉价感情. 提交于 2019-12-05 03:35:29
im trying to activate the debug logging for my Apache HttpClient but cant make it work (getting no logging output at all which is HttpClient related). This is my log4j2 configuration im using at the moment: <?xml version="1.0" encoding="UTF-8"?> <configuration status="OFF"> <appenders> <Console name="console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{HH:mm:ss} [%t] %-5level %logger{36} - %msg%n" /> </Console> <RollingFile name="RollingRandomAccessFile" fileName="logs/test.log" filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz"> <PatternLayout> <Pattern> %d %p %c{1.} [%t] %m