public abstract class Request extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected String |
failureText |
protected boolean |
fromMemoryCache |
protected Interception |
interception |
protected String |
interceptionId |
protected List<Request> |
redirectChain |
protected CdpResponse |
response |
protected static Map<Integer,String> |
STATUS_TEXTS |
| 构造器和说明 |
|---|
Request() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected abstract void |
_abort(ErrorReasons errorCode) |
abstract void |
_continue(ContinueRequestOverrides overrides)
拦截请求时,该方法表示放行请求
|
abstract void |
_respond(ResponseForRequest response)
使用给定的响应来满足请求。
|
void |
abort()
中止请求。
|
void |
abort(ErrorReasons errorCode,
Integer priority)
中止请求。
|
ErrorReasons |
abortErrorReason()
最近中止请求的原因
|
protected boolean |
canBeIntercepted() |
abstract CDPSession |
client() |
void |
continueRequest()
继续请求
|
void |
continueRequest(ContinueRequestOverrides overrides)
通过可选的请求覆盖继续请求。
|
void |
continueRequest(ContinueRequestOverrides overrides,
Integer priority)
拦截请求时,该方法表示放行请求
要使用此功能,应使用 Page.setRequestInterception() 启用请求拦截。
|
ContinueRequestOverrides |
continueRequestOverrides()
如果允许继续拦截(即不调用 abort() 和 respond()),返回 continueRequest 的 ContinueRequestOverrides。
|
void |
enqueueInterceptAction(Runnable pendingHandler)
将异步请求处理程序添加到处理队列。
|
abstract String |
failure()
访问有关请求失败的信息。
|
abstract String |
fetchPostData()
从浏览器获取请求的 POST 数据。
|
void |
finalizeInterceptions()
等待挂起的拦截处理程序,然后决定如何完成请求拦截。
|
abstract Frame |
frame() |
protected void |
handleError(Exception e) |
abstract boolean |
hasPostData()
是否有请求体
当请求有 POST 数据时为 true。
|
abstract List<HeaderEntry> |
headers()
具有与请求关联的 HTTP 标头的对象。
|
abstract String |
id() |
abstract Initiator |
initiator()
请求的发起者。
|
InterceptResolutionState |
interceptResolutionState()
描述当前解析操作和优先级的 InterceptResolutionState 对象。
|
boolean |
isInterceptResolutionHandled()
如果拦截解析已处理,则为 true,否则为 false。
|
abstract boolean |
isNavigationRequest()
如果请求是当前帧导航的驱动程序,则为 True。
|
abstract String |
method()
使用的方法(GET、POST 等)
|
abstract String |
postData()
请求体数据
|
abstract <T extends Request> |
redirectChain()
重定向链
redirectChain 是为获取资源而发起的请求链。
|
abstract ResourceType |
resourceType()
包含渲染引擎感知到的请求的资源类型。
|
void |
respond(ResponseForRequest response)
使用给定的响应来满足请求。
|
void |
respond(ResponseForRequest response,
Integer priority)
使用给定的响应来满足请求。
|
abstract Response |
response()
request 对应的响应
|
ResponseForRequest |
responseForRequest()
如果允许拦截响应(即不调用 abort()),则使用 ResponseForRequest。
|
void |
setFromMemoryCache(boolean fromMemoryCache) |
abstract String |
url()
请求的 URL
|
protected volatile String interceptionId
protected volatile String failureText
protected volatile CdpResponse response
protected volatile boolean fromMemoryCache
protected final Interception interception
public abstract CDPSession client()
public abstract String id()
public abstract String url()
public ContinueRequestOverrides continueRequestOverrides()
public ResponseForRequest responseForRequest()
public ErrorReasons abortErrorReason()
public InterceptResolutionState interceptResolutionState()
InterceptResolutionState 包含:行动:InterceptResolutionAction 优先级?:数字
InterceptResolutionAction 是以下之一:abort、respond、continue、disabled、none 或 already-handled。
public boolean isInterceptResolutionHandled()
public void enqueueInterceptAction(Runnable pendingHandler)
pendingHandler - Runnableprotected abstract void _abort(ErrorReasons errorCode)
public abstract void _respond(ResponseForRequest response)
response - 响应public abstract void _continue(ContinueRequestOverrides overrides)
overrides - 重写请求的信息。public void finalizeInterceptions()
public abstract ResourceType resourceType()
public abstract String method()
public abstract String postData()
public abstract boolean hasPostData()
当请求有 POST 数据时为 true。
请注意,当数据太长或不易以解码形式提供时,当此标志为真时,HTTPRequest.postData() 可能仍然未定义。
在这种情况下,请使用 HTTPRequest.fetchPostData()。
public abstract String fetchPostData()
public abstract List<HeaderEntry> headers()
public abstract Response response()
public abstract Frame frame()
public abstract boolean isNavigationRequest()
public abstract Initiator initiator()
public abstract <T extends Request> List<T> redirectChain()
redirectChain 是为获取资源而发起的请求链。
请求链 - 如果服务器至少响应一个重定向,则该链将包含所有重定向的请求。public abstract String failure()
请求成功,返回null
protected boolean canBeIntercepted()
public void continueRequest()
public void continueRequest(ContinueRequestOverrides overrides)
要使用此功能,应使用 Page.setRequestInterception() 启用请求拦截。
overrides - (可选)应用于请求的可选覆盖。public void continueRequest(ContinueRequestOverrides overrides, Integer priority)
要使用此功能,应使用 Page.setRequestInterception() 启用请求拦截。
priority - 如果提供,则使用协作处理规则来解决拦截。否则,拦截将立即解决。overrides - 重写请求的信息。public void respond(ResponseForRequest response)
要使用此功能,应使用 Page.setRequestInterception() 启用请求拦截。
response - 满足请求的响应。public void respond(ResponseForRequest response, Integer priority)
要使用此功能,应使用 Page.setRequestInterception() 启用请求拦截。
response - 满足请求的响应。priority - 可选的)如果提供,则使用协作处理规则来解决拦截。否则,拦截将立即解决。public void abort()
要使用此功能,应使用 Page.setRequestInterception() 启用请求拦截。
public void abort(ErrorReasons errorCode, Integer priority)
要使用此功能,应使用 Page.setRequestInterception() 启用请求拦截。
errorCode - (可选)提供可选的错误代码。priority - (可选的)如果提供,则使用协作处理规则来解决拦截。否则,拦截将立即解决。protected void handleError(Exception e)
public void setFromMemoryCache(boolean fromMemoryCache)
Copyright © 2020–2025. All rights reserved.