Interface CefriumResourceInterceptor
- All Known Subinterfaces:
CefriumBrowser.RequestInterceptor
Sees every request a
CefriumBrowser makes, and may cancel it or
answer it instead of the network. Set it with
CefriumBrowser.setResourceInterceptor(CefriumResourceInterceptor). Unlike the navigation
client, it is NOT called on the UI thread: each method says which thread,
and an implementation must be thread-safe.-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanonCanSaveCookie(String url, String name, String value) Whether a cookie a response sets may be stored.default booleanonCanSendCookie(String url, String name, String value) Whether a cookie may be sent with a request.default voidonRequestFiltered(String url, String method, boolean blocked) Every request, after the block decision:blockedis true when the built-in ad filter orshouldBlockRequest(CefriumBrowser.ResourceRequest)refused it.default voidonResourceLoadComplete(String url, int statusCode, long receivedBytes) A request finished: its status code and the bytes it received.default voidonResourceRedirect(String oldUrl, String newUrl) A request was redirected tonewUrl.default voidonResourceResponse(String url, int statusCode) A response's headers arrived, with this status code.default voidonResponseData(String url, ByteBuffer chunk) A chunk of a response body, as it arrives (read only; the page gets it unchanged).default booleanNetwork thread, synchronous: return true to cancel the request.default CefriumContentResponseBackground thread, may block (read a file, a database): return a response to answer the request yourself, or null to let it go to the network.
-
Method Details
-
shouldBlockRequest
Network thread, synchronous: return true to cancel the request. Called for every request, so it must be fast; do not block here. -
shouldInterceptRequest
Background thread, may block (read a file, a database): return a response to answer the request yourself, or null to let it go to the network. Like WebView'sshouldInterceptRequest, for any URL, with the request's method, headers and body. Range requests andHEADare handled for you, as for aCefriumContentServer. Called aftershouldBlockRequest(CefriumBrowser.ResourceRequest)let the request through; the request waits for the answer. -
onRequestFiltered
Every request, after the block decision:blockedis true when the built-in ad filter orshouldBlockRequest(CefriumBrowser.ResourceRequest)refused it. Network thread. -
onResourceRedirect
-
onResourceResponse
A response's headers arrived, with this status code. Network thread. -
onResourceLoadComplete
A request finished: its status code and the bytes it received. Network thread. -
onResponseData
A chunk of a response body, as it arrives (read only; the page gets it unchanged). Network thread. Overriding it copies every body across, so only override it when needed. -
onCanSendCookie
-
onCanSaveCookie
-