Thank you for your help.
I'll read the HttpClientTutorial, I hope it will help me.
Michaël


olegk wrote:
> 
> Michaël wrote:
>> Hi all, I'm doing a Get and Post method for an android project and I need
>> to
>> "translate" HttpClient 3.x to HttpClient 4.x (using by android). My
>> problem
>> is that I'm not sure of what I have done and I don't find the
>> "translation"
>> of some methods...
>> 
>> This is the HttpClient 3.x I have done and (-->) the HttpClient 4.x
>> "translation" if I have found it (Only parties who ask me problems) :
>> 
>> HttpState state = new HttpState (); --> ?
>> 
>> HttpMethod method = null; --> HttpUriRequest httpUri = null;
>> 
>> method.abort(); --> httpUri.abort(); //httpUri is a HttpUriRequest
>> 
>> method.releaseConnection(); --> conn.disconnect(); //conn is a
>> HttpURLConnection
>> 
>> state.clearCookies(); --> cookieStore.clear(); //cookieStore is a
>> BasicCookieStore
>> 
>> HttpClient client = new HttpClient(); --> HttpClient client;
>> 
>> client.getHttpConnectionManager().getParams().setConnectionTimeout(SOCKET_TIMEOUT)
>> --> HttpConnectionParams.setConnectionTimeout(param, SOCKET_TIMEOUT);
>> 
>> client.setState(state); --> ?
>> 
>> client.getParams().setCookiePolicy(CookiePolicy.RFC_2109); -->
>> HttpClientParams.setCookiePolicy(param, CookiePolicy.RFC_2109);
>> 
>> PostMethod post = (PostMethod) method; --> ?
>> 
>> post.setRequestHeader(...,...); --> conn.setRequestProperty(...,...);
>> 
>> post.setFollowRedirects(false); --> conn.setFollowRedirects(false);
>> 
>> RequestEntity tmp = null; --> ?
>> 
>> tmp = new StringRequestEntity(...,...,...); --> ?
>> 
>> int statusCode = client.executeMethod(post); --> ?
>> 
>> String ret = method.getResponsBodyAsString(); --> ?
>> 
>> Header locationHeader = method.getResponseHeader(...); --> ?
>> 
>> ret = getPage(...,...); --> ?
>> 
>> I don't know if that is correct. This has caused problems because the
>> packages are not named similarly, and some methods too. I just need
>> documentation (I haven't found) and little help.
>> 
>> Thank you in advance for your help. 
>> Michaël
>> 
> 
> Michaël,
> 
> The 4.0 API is very different from 3.x and quite often there are no 
> direct equivalents of old classes / methods. I suggest that you take a 
> look at the HttpClient 4.0 tutorial [1] and sample code [2] and redesign 
> your code based on the recommended use patterns.
> 
> Hope this helps
> 
> Oleg
> 
> [1] http://wiki.apache.org/HttpComponents/HttpClientTutorial
> [2] http://hc.apache.org/httpcomponents-client/examples.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Android-project-using-httpclient-%E2%80%94%3E-http.client-%28apache%29%2C-post-get-method-tp23582004p23584095.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to