How to handle the session in HttpClient 4.1
2012-10-19 21:32
369 查看
The correct way is to prepare a
CookieStorewhich you need to set in the
HttpContextwhich you in turn pass on every
HttpClient#execute()call.
HttpClient httpClient = new DefaultHttpClient(); CookieStore cookieStore = new BasicCookieStore(); HttpContext httpContext = new BasicHttpContext(); httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); // ... HttpResponse response1 = httpClient.execute(method1, httpContext); // ... HttpResponse response2 = httpClient.execute(method2, httpContext); // ...
相关文章推荐
- How to handle the space in column with awk?
- how to config the tftpd-hpa server in the ubuntu using for remote tftp client '-p' and '-r' command
- [Python]How to handle the exception in Python?
- How to improve the ef4.1 where handle the large data
- [Python]How to handle the exception in Python?
- [RxJS] How To get the results of two HTTP requests made in sequence
- What is the best way to handle Invalid CSRF token found in the request when session times out in Spring security
- how to handle the c string and comments in flex
- How to get the handle in windows using python
- How to ignore SSL certificate errors in Apache HttpClient 4.4
- How to change the price range in layered navigation in Magento? - See more at: http://www.expertweba
- How to cal Session_End() method when you store the Session state not in Inprc but StageServer, etc.
- scala: How to write a simple HTTP GET request client in Scala (with a timeout)
- How to execute an OS command in SQL*PLUS without leaving the session ?
- How to get the HttpServletRequest in Struts 2
- How to edit the init.rc in android
- How To Find The Top Wrinkle Cream In 5 Easy Steps
- How to Change Default Grub Theme or Splash Image in Ubuntu 10.10
- How to choose the right data structure in different scenarios to bring out best performance?
- how to deal with the situation that the language support option disappears in linux ubuntu