apache-commons-httpclient

PostMethod setRequestBody(String) deprecated - why?

蓝咒 提交于 2019-11-28 08:54:51
I am using Apache Commons HttpClient PostMethod 3.1. In the PostMethod class there are also three methods for setting POST method's request body: setRequestBody(InputStream body) setRequestBody(String body) setRequestBody(NameValuePair[] parametersBody); NameValuePair API First two methods are deprecated. Does anybody knows why? Because if I want to put an XML to request body, NameValuePair does not help me. Does anybody knows an workaround or a solution? The javadoc says: Deprecated. use setRequestEntity(RequestEntity) RequestEntity has a lot of implementors, namely: ByteArrayRequestEntity,

Disable Keep Alive in Apache HttpClient

爷,独闯天下 提交于 2019-11-28 08:34:07
问题 For some problem that we couldn't solve, I want to disable keep alive on Apache HttpClient 3.1. However, I couldn't find any resource on the Internet for that. Do you know how to do it? 回答1: You can disable HTTP 1.1 support on you method, i.e. httpMethod.setHttp11(false); but you will lost some other features. You can also try to force the connection header to ask the server to close the connection after its response: httpMethod.setRequestHeader("Connection", "close") . 来源: https:/

Using Apache HTTPClient - how can one see the raw request string before it's being sent?

走远了吗. 提交于 2019-11-28 08:20:41
For debugging purposes, I'd like to see the raw request that is going to be sent. Is there a way to get this without a HTTP monitor directly from the API of HttpPost or HttpClient ? I found some "almost" duplicate questions, but not for this particular one You can set some environment variables for Apache HttpClient (example tested for 4.3.2). System.setProperty("org.apache.commons.logging.Log","org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache

Why Warning:Unable to find optional library: org.apache.http.legacy occurs?

删除回忆录丶 提交于 2019-11-28 05:19:31
My gradle file: apply plugin: 'com.android.application' android { useLibrary 'org.apache.http.legacy' compileSdkVersion 23 buildToolsVersion "23.0.0" defaultConfig { applicationId "com.skripsi.irwanto.paud" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProauardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.11 } And I get Warning:Unable to find optional

Using Apache HttpClient how to set the TIMEOUT on a request and response

北慕城南 提交于 2019-11-27 20:12:52
问题 I need to set time out for the Http Request we make to a service (not a web service). We are using Apache HTTP Client. I have added these 2 lines of code to set the time out on request and response to the service. HttpConnectionParams.setConnectionTimeout(params, 10000); HttpConnectionParams.setSoTimeout(params, 10000); 1) Currently I have set 10 seconds as the timeout since I see the response coming from the service almost instantaneously. Should I increase or decrease the timing? 2) What

How to POST JSON request using Apache HttpClient?

老子叫甜甜 提交于 2019-11-27 17:39:30
I have something like the following: final String url = "http://example.com"; final HttpClient httpClient = new HttpClient(); final PostMethod postMethod = new PostMethod(url); postMethod.addRequestHeader("Content-Type", "application/json"); postMethod.addParameters(new NameValuePair[]{ new NameValuePair("name", "value) }); httpClient.executeMethod(httpMethod); postMethod.getResponseBodyAsStream(); postMethod.releaseConnection(); It keeps coming back with a 500. The service provider says I need to send JSON. How is that done with Apache HttpClient 3.1+? Apache HttpClient doesn't know anything

How to use DefaultHttpClient in Android? [closed]

筅森魡賤 提交于 2019-11-27 16:35:07
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . How to use DefaultHttpClient in Android? 回答1: I suggest reading the tutorials provided with android-api. Here is some random example which uses DefaultHttpClient, found by simple text-search in examples-folder.

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

情到浓时终转凉″ 提交于 2019-11-27 12:45:45
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 MultiThreadedHttpConnectionManager(); this.httpClient = new HttpClient(connMgr); // initialize HttpClient parameters

Duplicate files during packaging of APK app-debug-unaligned.apk

天大地大妈咪最大 提交于 2019-11-27 11:26:36
问题 I got this error Duplicate files during packaging of APK app-debug-unaligned.apk when put 2 jar files : httpclient-4.3.5.jar httpmime-4.3.5.jar into the libs folder after Sync with Gradle and Run . If user 1 jar file - httpmime-4.3.5.jar , I will not get this error. Please help me how to avoid this error & still can use 2 jar files in above also, Thanks, p/s : I use Android Studio version 0.8.6. Error Detail Error:duplicate files during packaging of APK ...\app\build\outputs\apk\app-debug

Does Apache Commons HttpClient support GZIP?

吃可爱长大的小学妹 提交于 2019-11-27 08:15:11
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). Apache HttpClient 4.1 supports content compression out of the box along with many other features that were previously considered out of scope. If your server is able to provide GZIPped content, with Apache Http client 4.1 all you need is to use org.apache.http.impl.client.ContentEncodingHttpClient which is a subclass of DefaultHttpClient . This