本文整理汇总了Java中org.apache.http.cookie.Cookie.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Cookie.getValue方法的具体用法?Java Cookie.getValue怎么用?Java Cookie.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.cookie.Cookie
的用法示例。
在下文中一共展示了Cookie.getValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveCookies
import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
public void saveCookies(List<Cookie> cookies){
String strCookie = "";
Date sessionTime = null;
if (cookies != null && !cookies.isEmpty()) {
for (int i = 0; i < cookies.size(); i++) {
Cookie cookie = cookies.get(i);
if (cookie.getName().equalsIgnoreCase("JSESSIONID")){
strCookie += cookie.getName() + "="
+ cookie.getValue() + ";domain="
+cookie.getDomain();
sessionTime = cookies.get(i).getExpiryDate();
}
}
}
editor.putString("cookies", strCookie);
editor.commit();
editor.putString("cookiesExpiryDate", (sessionTime == null)?null:TimeUtil.getDTFormat().format(sessionTime));
editor.commit();
}
示例2: formatCookies
import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
public List<Header> formatCookies(final List<Cookie> cookies) {
if (cookies == null) {
throw new IllegalArgumentException("List of cookies may not be null");
}
if (cookies.isEmpty()) {
throw new IllegalArgumentException("List of cookies may not be empty");
}
CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
buffer.append(SM.COOKIE);
buffer.append(": ");
for (int i = 0; i < cookies.size(); i++) {
Cookie cookie = cookies.get(i);
if (i > 0) {
buffer.append("; ");
}
buffer.append(cookie.getName());
String s = cookie.getValue();
if (s != null) {
buffer.append("=");
buffer.append(s);
}
}
List<Header> headers = new ArrayList<Header>(1);
headers.add(new BufferedHeader(buffer));
return headers;
}
示例3: formatCookies
import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
public List<Header> formatCookies(final List<Cookie> cookies) {
if (cookies == null) {
throw new IllegalArgumentException("List of cookies may not be null");
}
if (cookies.isEmpty()) {
throw new IllegalArgumentException("List of cookies may not be empty");
}
CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
buffer.append(SM.COOKIE);
buffer.append(": ");
for (int i = 0; i < cookies.size(); i++) {
Cookie cookie = cookies.get(i);
if (i > 0) {
buffer.append("; ");
}
buffer.append(cookie.getName());
buffer.append("=");
String s = cookie.getValue();
if (s != null) {
buffer.append(s);
}
}
List<Header> headers = new ArrayList<Header>(1);
headers.add(new BufferedHeader(buffer));
return headers;
}
示例4: makeHttpRequest
import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
@Override
protected HttpResponse makeHttpRequest(HttpEntity entity, long startTime) {
if (entity != null) {
requestBuilder.setEntity(entity);
requestBuilder.setHeader(entity.getContentType());
}
HttpUriRequest httpRequest = requestBuilder.build();
CloseableHttpClient client = clientBuilder.build();
BasicHttpContext context = new BasicHttpContext();
context.setAttribute(URI_CONTEXT_KEY, getRequestUri());
CloseableHttpResponse httpResponse;
byte[] bytes;
try {
httpResponse = client.execute(httpRequest, context);
HttpEntity responseEntity = httpResponse.getEntity();
if (responseEntity == null || responseEntity.getContent() == null) {
bytes = new byte[0];
} else {
InputStream is = responseEntity.getContent();
bytes = FileUtils.toBytes(is);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
long responseTime = getResponseTime(startTime);
HttpResponse response = new HttpResponse(responseTime);
response.setUri(getRequestUri());
response.setBody(bytes);
response.setStatus(httpResponse.getStatusLine().getStatusCode());
for (Cookie c : cookieStore.getCookies()) {
com.intuit.karate.http.Cookie cookie = new com.intuit.karate.http.Cookie(c.getName(), c.getValue());
cookie.put(DOMAIN, c.getDomain());
cookie.put(PATH, c.getPath());
if (c.getExpiryDate() != null) {
cookie.put(EXPIRES, c.getExpiryDate().getTime() + "");
}
cookie.put(PERSISTENT, c.isPersistent() + "");
cookie.put(SECURE, c.isSecure() + "");
response.addCookie(cookie);
}
cookieStore.clear(); // we rely on the StepDefs for cookie 'persistence'
for (Header header : httpResponse.getAllHeaders()) {
response.addHeader(header.getName(), header.getValue());
}
return response;
}
示例5: getCookieValue
import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
public static String getCookieValue(List<Cookie> cookies, String cookieName){
Cookie cookie = getCookie(cookies, cookieName);
if(cookie == null){
return null;
}
return cookie.getValue();
}
示例6: getCaptchaId
import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
private String getCaptchaId(HttpClient httpClient) {
List<Cookie> cookies = ((AbstractHttpClient) httpClient).getCookieStore().getCookies();
String captchaId = null;
for (int i = 0; i < cookies.size(); i++) {
Cookie cookie = (Cookie) cookies.get(i);
String cookieName = cookie.getName();
if (!TextUtils.isEmpty(cookieName) && cookieName.equals("captchaId")) {
captchaId = cookie.getValue();
}
}
return captchaId;
}
示例7: getCurrentSession
import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
private String getCurrentSession(HttpClientContext clientContext){
for (Cookie cookie : clientContext.getCookieStore().getCookies()){
if(cookie.getName().equals("JSESSIONID")){
return cookie.getValue();
}
}
logger.error("no active JSESSIONID found.");
return null;
}
示例8: detectCookie
import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
public String detectCookie(String key) {
List<Cookie> cookies = status.getCookies();
for (Cookie cookie : cookies) {
if (cookie.getName().equals(key)) {
return cookie.getValue();
}
}
return null;
}
示例9: DCookieStore
import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
public DCookieStore(DSession permanentSession) {
this.permanentSession = permanentSession;
if (this.permanentSession != null && this.permanentSession.getCookies() != null) {
for (Cookie cookie : this.permanentSession.getCookies()) {
BasicClientCookie bcc = new BasicClientCookie(cookie.getName(), cookie.getValue());
bcc.setDomain(((BasicClientCookie)cookie).getDomain());
bcc.setPath(((BasicClientCookie)cookie).getPath());
bcc.setVersion(((BasicClientCookie)cookie).getVersion());
super.addCookie(bcc);
}
}
}
示例10: getSessionMap
import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
private Map<String, Object> getSessionMap() {
Map<String, Object> sessionMap = new HashMap<String, Object>();
String sessionId = null;
Date maxAge = null;
for (Cookie cookie : cookies) {
if (SESSION_ID.equals(cookie.getName())) {
sessionId = cookie.getValue();
maxAge = cookie.getExpiryDate();
}
}
sessionMap.put(SESSION_ID, sessionId);
sessionMap.put(MAX_AGE, maxAge);
return sessionMap;
}