Click or drag to resize
IResourceHandler Interface
Version 63.0.0
Class used to implement a custom resource handler. The methods of this class will always be called on the CEF IO thread. Blocking the CEF IO thread will adversely affect browser performance. We suggest you execute your code in a Task (or similar). To implement async handling, spawn a new Task (or similar), keep a reference to the callback. When you have a fully populated stream, execute the callback. Once the callback Executes, GetResponseHeaders will be called where you can modify the response including headers, or even redirect to a new Url. Set your responseLength and headers Populate the dataOut stream in ReadResponse. For those looking for a sample implementation or upgrading from a previous version ResourceHandler. For those upgrading, inherit from ResourceHandler instead of IResourceHandler add the override keywoard to existing methods e.g. ProcessRequestAsync.

Namespace: CefSharp
Assembly: CefSharp (in CefSharp.dll) Version: 63.0.0.0 (63.0.0.0)
Syntax
public interface IResourceHandler : IDisposable

The IResourceHandler type exposes the following members.

Methods
  NameDescription
Public methodCancel
Request processing has been canceled.
Public methodCanGetCookie
Return true if the specified cookie can be sent with the request or false otherwise. If false is returned for any cookie then no cookies will be sent with the request.
Public methodCanSetCookie
Return true if the specified cookie returned with the response can be set or false otherwise.
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from IDisposable.)
Public methodGetResponseHeaders
Retrieve response header information. If the response length is not known set responseLength to -1 and ReadResponse() will be called until it returns false. If the response length is known set responseLength to a positive value and ReadResponse() will be called until it returns false or the specified number of bytes have been read. If an error occured while setting up the request you can set ErrorCode to indicate the error condition.
Public methodProcessRequest
Begin processing the request.
Public methodReadResponse
Read response data. If data is available immediately copy to dataOut, set bytesRead to the number of bytes copied, and return true. To read the data at a later time set bytesRead to 0, return true and call ICallback.Continue() when the data is available. To indicate response completion return false.
Top
See Also