HttpURLConnection 如何设置请求cookie

使用HttpURLConnection 如何设置请求cookie呢?

huc.addRequestProperty("content-type", contentType);
		if (ValueWidget.isHasValue(cookie)) {
			huc.setRequestProperty("Cookie", cookie);
		}

如何获取应答的cookie呢?

String session_value = huc

.getHeaderField(SystemHWUtil.KEY_HEADER_COOKIE);

SystemHWUtil.KEY_HEADER_COOKIE的值为"Set-Cookie"

public static final String  KEY_HEADER_COOKIE="Set-Cookie";

猜你喜欢

转载自hw1287789687.iteye.com/blog/2240085