apache-httpclient-4.x

java apache HC BasicHttpEntityEnclosingRequest vs BasicHttpRequest

大兔子大兔子 提交于 2019-12-23 04:11:43
问题 Making a class that takes instructions (steps) from a data source and automates few HC (http://hc.apache.org Apache Http Client) actions. Want to be able to carry out HTTP post, get and direct (like sending a JSON or XML/ soap message to a web server) calls. Confused about when to use BasicHttpEntityEnclosingRequest vs BasicHttpReques what is the enclosing? Right now I have steps to init the context, provide param values, the URL, method etc when i want to submit this is what I'm doing:

java apache HC BasicHttpEntityEnclosingRequest vs BasicHttpRequest

六月ゝ 毕业季﹏ 提交于 2019-12-23 04:11:33
问题 Making a class that takes instructions (steps) from a data source and automates few HC (http://hc.apache.org Apache Http Client) actions. Want to be able to carry out HTTP post, get and direct (like sending a JSON or XML/ soap message to a web server) calls. Confused about when to use BasicHttpEntityEnclosingRequest vs BasicHttpReques what is the enclosing? Right now I have steps to init the context, provide param values, the URL, method etc when i want to submit this is what I'm doing:

HTTPClient - Capture a list of all Redirects

时间秒杀一切 提交于 2019-12-23 03:36:16
问题 Is it possible to capture the full redirect history from a URL using HttpClient? Say for example we have URL-A which redirects to URL-B which finally sends us to URL-C, is there a way to capture what URLs A, B and C were? The most obvious option is to manually look for the location tag in the header, and stop when we reach a HTTP 200. This isnt a simple process as we would need to look for circular redirects etc etc... Now I'm assuming the something along the lines of: HttpContext context =

HTTPClient - NoSuchMethodError for .releaseConnection

和自甴很熟 提交于 2019-12-23 01:52:12
问题 I am building a testing project using HTTPClient to test restful services. Here is the code that I am so far successfully using to get a 200 OK response on a GET. However, I am getting an error on .releaseConnection, which the HTTPClient documentation says is important to use. Code: public class Container { public String tryGet() { String getResult = null; DefaultHttpClient httpclient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet("http://test.url"); try { HttpResponse response1 =

How to configure the number of allowed pending requests in Apache async client

喜欢而已 提交于 2019-12-22 18:09:35
问题 I'm developing an HTTP client application, using Apache httpasyncclient version 4.0.2. I would like to configure the maximum number of pending requests. Initially I assumed this number is the same as the maximum number of connections. I set this to 20 in the following way: final CloseableHttpAsyncClient httpclient; In the constructor: final NHttpConnectionFactory<ManagedNHttpClientConnection> connFactory = new ManagedNHttpClientConnectionFactory(new DefaultHttpRequestWriterFactory(), new

How to determine the maximum number of simultaneous connections for a given `HttpClient` instance

淺唱寂寞╮ 提交于 2019-12-22 17:06:09
问题 I have a Servlet that builds an HttpClient instance when it starts. It shares this client with a collaborating module used when servicing requests. I would like to use the FutureRequestExecutionService API within the collaborating module to easily send some requests concurrently. This requires using an HttpClient instance along with an ExecutorService instance. The tutorial recommends setting the ExecutorService to use the same number of threads as the HttpClient 's maximum number of

java char encoding for strange string from API

 ̄綄美尐妖づ 提交于 2019-12-22 11:25:41
问题 I'm having strange issue with a response got from API. I'm using apache HTTP Client to get response. Response header has the following Content-Type=[application/json; charset=utf-16] Transfer-Encoding=[chunked] X-Powered-By=[ASP.NET] // Yes, people using ASP.NET So based on this, when I get response, my response looks like follows 笀∀匀琀愀琀甀猀䌀漀搀攀∀㨀㈀  So I tried the following. String body = "笀∀匀琀愀琀甀猀䌀漀搀攀∀㨀㈀"; String charSetString = "utf-8|utf-16|utf-16le, all possible combination" body = new

RestEasy Client Authentication and HTTP Put with Marshalling

两盒软妹~` 提交于 2019-12-22 08:08:40
问题 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

Java not sending client certificate

断了今生、忘了曾经 提交于 2019-12-22 08:04:13
问题 I'm using HttpClient 4.2.3 on Java 1.7 to connect to a remote server hosted by nginx. My organization uses PKI extensively, and both the remote and the client have certificates issued by a common CA. The server has a signing chain like the following: CN=Server 123, OU=Servers, OU=My Division, O=My Org, C=US CN=My Division CA, OU=My Division, O=My Org, C=US CN=My Org CA, O=My Org, C=US And the client has a signing chain like the following: CN=Client 456, OU=Servers, OU=My Division, O=My Org, C

For a HttpGet method what are getParams()?

穿精又带淫゛_ 提交于 2019-12-22 06:49:03
问题 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 回答1: 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