httpclient获取响应头信息

String _cookies = getCookieStr(postMethod.getResponseHeader("Set-Cookie"));

 

 

private String getCookieStr(Header header) {

StringBuilder sb = new StringBuilder();

HeaderElement[] elements = header.getElements();

for (int i = 0; i < elements.length; i++) {

HeaderElement element = elements[i];

if (!StringUtils.isEmpty(element.getName())) {

sb.append(element.getName().trim());

sb.append("=");

sb.append(element.getValue());

sb.append(";");

}

}

return sb.toString();

}

 

 

你可能感兴趣的:(httpclient)