public abstract class CookieHandler extends Object
全系统cookiehandler,通过HTTP协议处理程序的应用可以通过一个cookiehandler注册。setdefault(cookiehandler)。目前注册cookiehandler可以通过调用CookieHandler getdefault()检索。基于HTTP协议的状态管理的更多信息,见RFC 2965: HTTP State Management Mechanism
Constructor and Description |
---|
CookieHandler() |
Modifier and Type | Method and Description |
---|---|
abstract Map<String,List<String>> |
get(URI uri, Map<String,List<String>> requestHeaders)
从一个请求标头中指定的URI的cookie缓存中获取所有适用的饼干。
|
static CookieHandler |
getDefault()
获取系统范围的饼干处理程序。
|
abstract void |
put(URI uri, Map<String,List<String>> responseHeaders)
集所有适用的饼干,例如响应头域,被命名为set-cookie2,目前在响应头到一个cookie缓存。
|
static void |
setDefault(CookieHandler cHandler)
集(或设定)系统范围的cookie处理程序。
|
public static CookieHandler getDefault()
SecurityException
如果安全管理器已经安装,它否认
NetPermission
("getCookieHandler")
setDefault(CookieHandler)
public static void setDefault(CookieHandler cHandler)
cHandler
- HTTP cookie处理程序,或
null
未设置。
SecurityException
如果安全管理器已经安装,它否认
NetPermission
("setCookieHandler")
getDefault()
public abstract Map<String,List<String>> get(URI uri, Map<String,List<String>> requestHeaders) throws IOException
作为一个参数传递的URI
指定用途的饼干。具体的方案应该反映是否饼干将发送HTTP、HTTPS或用在另一种情况下,如JavaScript。主机部分应反映目标的饼干或者在JavaScript的案件来源。
要实现考虑到URI
和饼干的属性和安全设置,以确定哪些应该归还。
HTTP协议的实施者应确保该方法添加后都选择饼干相关请求报头,并发送请求之前。
uri
-
URI
代表使用的饼干
requestHeaders
-Map从请求标头字段名称列表的字段的值表示当前请求报头
IOException
如果I/O错误发生
IllegalArgumentException
-如果任一参数为null
put(URI, Map)
public abstract void put(URI uri, Map<String,List<String>> responseHeaders) throws IOException
uri
-
URI
饼干是从哪里来的
responseHeaders
从字段名称列表字段值代表响应头域不变的Map返回
IOException
如果I/O错误发生
IllegalArgumentException
-如果任一参数为null
get(URI, Map)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.