apache-commons-httpclient

Android session management

非 Y 不嫁゛ 提交于 2019-11-27 06:41:49
Is there a specific library for Android session management? I need to manage my sessions in a normal Android app. not in WebView . I can set the session from my post method. But when I send another request that session is lost. Can someone help me with this matter? DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("My url"); HttpResponse response = httpClient.execute(httppost); List<Cookie> cookies = httpClient.getCookieStore().getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out

How can I override the “Host” header in the request when using Apache commons HttpClient

会有一股神秘感。 提交于 2019-11-27 05:58:06
问题 I am using Jakarta Commons HttpClient 3.1 writing a load test tool that needs to target different servers and pretend like it targeted the correct virtual host in the HTTP server. For that I need to be able to set the "Host" HTTP header in the request to a different host name then the actual host name that I'm connecting to. It seemed pretty obvious that I should use Method.setRequestHeader("Host","fakehostname") , but HttpClient just ignores this and always sends the real host name I'm

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

天涯浪子 提交于 2019-11-27 05:46:44
问题 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 回答1: 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

PostMethod setRequestBody(String) deprecated - why?

元气小坏坏 提交于 2019-11-27 02:30:38
问题 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? 回答1: The javadoc says: Deprecated.

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

孤街醉人 提交于 2019-11-27 00:53:24
问题 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

How to POST JSON request using Apache HttpClient?

て烟熏妆下的殇ゞ 提交于 2019-11-26 22:34:54
问题 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

Best Practice to Use HttpClient in Multithreaded Environment

本秂侑毒 提交于 2019-11-26 19:19:47
For a while, I have been using HttpClient in a multithreaded environment. For every thread, when it initiates a connection, it will create a completely new HttpClient instance. Recently, I have discovered that, by using this approach, it can cause the user to have too many ports being opened, and most of the connections are in TIME_WAIT state. http://www.opensubscriber.com/message/commons-httpclient-dev@jakarta.apache.org/86045.html Hence, instead of each thread doing : HttpClient c = new HttpClient(); try { c.executeMethod(method); } catch(...) { } finally { method.releaseConnection(); } We

Apache http client or URLConnection [duplicate]

爱⌒轻易说出口 提交于 2019-11-26 17:30:43
问题 This question already has answers here : URLConnection or HTTPClient : Which offers better functionality and more efficiency? (6 answers) Closed 3 years ago . I need to download a web page on an android app and I am having a hard time deciding whether to use the android apache http client or java's URLConnection. Any thoughts? 回答1: For most things I'd say that HttpClient is the way to go. However there are some situations and edge cases where I'd fall back to a URLConnection . Examples of

How to enable logging for apache commons HttpClient on Android

微笑、不失礼 提交于 2019-11-26 14:14:32
To enable logging for apache commons HttpClient in normal Java application I used: 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.httpclient.wire", "debug"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug"); But on android I don't see logs in LogCat. Am I missing some thing? Joe Ignore my earlier comment. I found the solution on the org.apache.http

Using Apache httpclient for https

拥有回忆 提交于 2019-11-26 12:36:47
问题 I have enabled https in tomcat and have a self-signed certificate for server auth. I have created an http client using Apache httpClient. I have set a trust manager loading the server certificate. The http client can connect with server no problem. To see what is going on I enabled debugging: System.setProperty(\"javax.net.debug\", \"ssl\"); I saw the following which I can not understand at all: *** adding as trusted cert: Subject: CN=Me, OU=MyHouse, O=Home, L=X, ST=X, C=BB Issuer: CN=Me, OU