public class Request extends Object
'request' emitted when the request is issued by the page. 'response' emitted when/if the response is received for the request. 'requestfinished' emitted when the response body is downloaded and the request is complete. If request fails at some point, then instead of 'requestfinished' event (and possibly instead of 'response' event), the 'requestfailed' event is emitted.
NOTE HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with 'requestfinished' event.
If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new request is issued to a redirected url.
| 构造器和说明 |
|---|
Request() |
Request(CDPSession client,
Frame frame,
String interceptionId,
boolean allowInterception,
RequestWillBeSentPayload event,
List<Request> redirectChain) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
abort() |
Future<com.fasterxml.jackson.databind.JsonNode> |
abort(ErrorCode errorCode)
拒绝发请求
|
void |
continueRequest()
请求继续
|
Future<com.fasterxml.jackson.databind.JsonNode> |
continueRequest(String url,
String method,
String postData,
Map<String,String> headers)
continue()方法,但是continue是java关键字,所以改成了continueRequest
|
String |
failure()
返回请求的失败信息
|
Frame |
frame() |
boolean |
fromMemoryCache() |
Map<String,String> |
headers() |
String |
interceptionId() |
boolean |
isAllowInterception() |
boolean |
isInterceptionHandled() |
boolean |
isNavigationRequest() |
String |
method() |
String |
postData() |
List<Request> |
redirectChain() |
String |
requestId() |
String |
resourceType() |
Future<com.fasterxml.jackson.databind.JsonNode> |
respond(int status,
Map<String,String> headers,
String contentType,
String body)
自定义响应
|
Response |
response() |
protected void |
setFailureText(String failureText) |
protected void |
setFromMemoryCache(boolean fromMemoryCache) |
protected void |
setInterceptionHandled(boolean interceptionHandled) |
protected void |
setResponse(Response response) |
String |
url() |
public Request()
public Request(CDPSession client, Frame frame, String interceptionId, boolean allowInterception, RequestWillBeSentPayload event, List<Request> redirectChain)
public Frame frame()
public String interceptionId()
public boolean isAllowInterception()
public String failure()
public Future<com.fasterxml.jackson.databind.JsonNode> continueRequest(String url, String method, String postData, Map<String,String> headers)
url - urlmethod - 方法 GET POSTpostData - 数据 the post data of requestheaders - 请求头public void continueRequest()
public Future<com.fasterxml.jackson.databind.JsonNode> respond(int status, Map<String,String> headers, String contentType, String body)
status - 响应状态headers - 响应头contentType - contentTypebody - 响应体public Future<com.fasterxml.jackson.databind.JsonNode> abort(ErrorCode errorCode)
errorCode - errorCode错误码public void abort()
public Response response()
public String url()
public String method()
public String postData()
protected void setResponse(Response response)
public String requestId()
public boolean isNavigationRequest()
public boolean isInterceptionHandled()
protected void setInterceptionHandled(boolean interceptionHandled)
protected void setFailureText(String failureText)
public String resourceType()
public boolean fromMemoryCache()
protected void setFromMemoryCache(boolean fromMemoryCache)
Copyright © 2020. All rights reserved.