apache-httpclient-4.x

Does Apache JMeter support http/2 requests?

做~自己de王妃 提交于 2019-11-30 22:05:13
Does JMeter 3.2 support HTTP2 ? From HTTPClient 4.5 official docs : Standards based, pure Java, implementation of HTTP versions 1.0 and 1.1 SO, you need to wait till HTTP/2 is implemented in HTTPClient libraries and Jmeter implements HTTP2 using the library and create a sampler for the same. To sample HTTP/2 requests, you can use a plugin for jmeter, such as this one: https://github.com/syucream/jmeter-http2-plugin From the readme file: Build Netty 5 (Alpha3+) and netty-tcnative for your platform Copy HTTP2Sampler.jar, netty-all.jar, netty-tcnative.jar and hpack.jar to lib/ext of jmeter

How Do We Enable SNI in HttpClient 4.4+ on Android?

三世轮回 提交于 2019-11-30 22:04:23
I am trying to work out recipes for using SNI with major HTTP stacks on modern versions of Android. This includes Apache's separate HttpClient library ( not the version baked into Android itself, which is dead and gone). It appears that recent versions of HttpClient do not support SNI out of the box. When I use the 'cz.msebera.android:httpclient:4.4.1.1' artifact, I get: javax.net.ssl.SSLPeerUnverifiedException: Host name '...' does not match the certificate subject provided by the peer (CN=...) at cz.msebera.android.httpclient.conn.ssl.SSLConnectionSocketFactory.verifyHostname

Exit from HttpClient session

烂漫一生 提交于 2019-11-30 20:12:15
How to exit from HttpClient session? I use the following code to login to the application using Apache HttpClient public HttpClient loginToHexgen(String username, String password) { HttpClient client = new DefaultHttpClient(); // send post url to login to hexgen HttpPost post = new HttpPost("http://localhost:8080/j_spring_security_check"); try { // set the user name and password List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1); nameValuePairs.add(new BasicNameValuePair("j_username", username)); nameValuePairs.add(new BasicNameValuePair("j_password", password)); post

How Do We Enable SNI in HttpClient 4.4+ on Android?

一笑奈何 提交于 2019-11-30 17:53:19
问题 I am trying to work out recipes for using SNI with major HTTP stacks on modern versions of Android. This includes Apache's separate HttpClient library ( not the version baked into Android itself, which is dead and gone). It appears that recent versions of HttpClient do not support SNI out of the box. When I use the 'cz.msebera.android:httpclient:4.4.1.1' artifact, I get: javax.net.ssl.SSLPeerUnverifiedException: Host name '...' does not match the certificate subject provided by the peer (CN=.

In Java, using HttpPost (apache commons HttpClient) when sending JSON POST - should I URL encode the body?

你。 提交于 2019-11-30 16:08:10
问题 I'm sending a RESTful JSON POST request using Apache HttpClient (to a 3rd party API) Should I URL encode the JSON body? And if something in the content is already URL encoded (e.g. I send HTML that has some links with URL encoded chars, e.g. @22) should I expect to get the content as is on the other side without it being decoded? E.g. if i'm doing something like this String html = "<a href='http://example.com?charOfTheDay=%22'>click me</a>"; // Build the JSON object JSONObject jsonObj = new

Conflict between httpclient version and Apache Spark

穿精又带淫゛_ 提交于 2019-11-30 14:48:23
I'm developing a Java application using Apache Spark. I use this version: <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-core_2.10</artifactId> <version>1.2.2</version> </dependency> In my code, there is a transitional dependency: <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.2</version> </dependency> I package my application into a single JAR file. When deploying it on EC2 instance using spark-submit , I get this error. Caused by: java.lang.NoSuchFieldError: INSTANCE at org.apache.http.conn.ssl

Android API 23 - HttpClient 4.X repackaged

*爱你&永不变心* 提交于 2019-11-30 14:21:05
Disclaimer I know we shouldn't use HttpClient on Android anymore In API 23 we have option to use useLibrary 'org.apache.http.legacy' I'd like to continue using HttpClient (also I maintain libraries and projects based on it) however, with API 23 the classes are gone. Well not gone with useLibrary workaround, but cannot be used to develop any further (classes don't autocomplete, everything is shown as invalid code) We also have option to use HttpComponents provided Android fork of HttpClient 4.3.5.1 , which however doesn't provide classes/headers/interfaces that Android provided on API < 22, so

Mocking Apache HTTPClient using Mockito

流过昼夜 提交于 2019-11-30 12:38:19
问题 I'm trying to mock Apache HttpClient Interface in order to mock one of its methods mentioned below to return a stubbed JSON object in response. HttpResponse response = defaultHttpClient.execute(postRequest); Could somebody be able to suggest how to achieve this with some sample code? Your help would be greatly appreciated. Thanks 回答1: Here is what I did to test my code using Mockito and Apache HttpBuilder: Class under test: import java.io.BufferedReader; import java.io.IOException; import

Google Java API conflicted with ColdFusion CFHTTP?

独自空忆成欢 提交于 2019-11-30 09:34:38
问题 I tried copying all those JAR's found in the google-api-client-assembly-1.20.0-1.20.01.zip (downloaded from https://developers.google.com/api-client-library/java/google-api-java-client/download) to {cf_root}/lib , restart ColdFusion, and everything loaded up fine. However, when I used <cfhttp> : org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [CfmServlet] in context with path [/] threw exception [org.apache.http.impl.client.DefaultHttpClient

HTTPClient sends out two requests when using Basic Auth?

蹲街弑〆低调 提交于 2019-11-30 08:41:10
I have been using HTTPClient version 4.1.2 to try to access a REST over HTTP API that requires Basic Authentication. Here is client code: DefaultHttpClient httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager()); // Enable HTTP Basic Auth httpClient.getCredentialsProvider().setCredentials( new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(this.username, this.password)); HttpHost proxy = new HttpHost(this.proxyURI.getHost(), this.proxyURI.getPort()); httpClient.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, proxy); When I construct a