Chromium Embedded Framework (CEF)  114.2.1+gd70a0a8+chromium-114.0.5735.45
CefResourceHandler Class Referenceabstract

Class used to implement a custom request handler interface. More...

#include "include/cef_resource_handler.h"

Inheritance diagram for CefResourceHandler:
CefBaseRefCounted CefStreamResourceHandler

Public Member Functions

virtual bool Open (CefRefPtr< CefRequest > request, bool &handle_request, CefRefPtr< CefCallback > callback)
 Open the response stream. More...
 
virtual bool ProcessRequest (CefRefPtr< CefRequest > request, CefRefPtr< CefCallback > callback)
 Begin processing the request. More...
 
virtual void GetResponseHeaders (CefRefPtr< CefResponse > response, int64 &response_length, CefString &redirectUrl)=0
 Retrieve response header information. More...
 
virtual bool Skip (int64 bytes_to_skip, int64 &bytes_skipped, CefRefPtr< CefResourceSkipCallback > callback)
 Skip response data when requested by a Range header. More...
 
virtual bool Read (void *data_out, int bytes_to_read, int &bytes_read, CefRefPtr< CefResourceReadCallback > callback)
 Read response data. More...
 
virtual bool ReadResponse (void *data_out, int bytes_to_read, int &bytes_read, CefRefPtr< CefCallback > callback)
 Read response data. More...
 
virtual void Cancel ()=0
 Request processing has been canceled. More...
 
- Public Member Functions inherited from CefBaseRefCounted
virtual void AddRef () const =0
 Called to increment the reference count for the object. More...
 
virtual bool Release () const =0
 Called to decrement the reference count for the object. More...
 
virtual bool HasOneRef () const =0
 Returns true if the reference count is 1. More...
 
virtual bool HasAtLeastOneRef () const =0
 Returns true if the reference count is at least 1. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CefBaseRefCounted
virtual ~CefBaseRefCounted ()
 

Detailed Description

Class used to implement a custom request handler interface.

The methods of this class will be called on the IO thread unless otherwise indicated.

Member Function Documentation

◆ Cancel()

virtual void CefResourceHandler::Cancel ( )
pure virtual

Request processing has been canceled.

Implemented in CefStreamResourceHandler.

◆ GetResponseHeaders()

virtual void CefResourceHandler::GetResponseHeaders ( CefRefPtr< CefResponse response,
int64 response_length,
CefString redirectUrl 
)
pure virtual

Retrieve response header information.

If the response length is not known set |response_length| to -1 and ReadResponse() will be called until it returns false. If the response length is known set |response_length| to a positive value and ReadResponse() will be called until it returns false or the specified number of bytes have been read. Use the |response| object to set the mime type, http status code and other optional header values. To redirect the request to a new URL set |redirectUrl| to the new URL. |redirectUrl| can be either a relative or fully qualified URL. It is also possible to set |response| to a redirect http status code and pass the new URL via a Location header. Likewise with |redirectUrl| it is valid to set a relative or fully qualified URL as the Location header value. If an error occured while setting up the request you can call SetError() on |response| to indicate the error condition.

Implemented in CefStreamResourceHandler.

◆ Open()

virtual bool CefResourceHandler::Open ( CefRefPtr< CefRequest request,
bool &  handle_request,
CefRefPtr< CefCallback callback 
)
inlinevirtual

Open the response stream.

To handle the request immediately set |handle_request| to true and return true. To decide at a later time set |handle_request| to false, return true, and execute |callback| to continue or cancel the request. To cancel the request immediately set |handle_request| to true and return false. This method will be called in sequence but not from a dedicated thread. For backwards compatibility set |handle_request| to false and return false and the ProcessRequest method will be called.

Reimplemented in CefStreamResourceHandler.

◆ ProcessRequest()

virtual bool CefResourceHandler::ProcessRequest ( CefRefPtr< CefRequest request,
CefRefPtr< CefCallback callback 
)
inlinevirtual

Begin processing the request.

To handle the request return true and call CefCallback::Continue() once the response header information is available (CefCallback::Continue() can also be called from inside this method if header information is available immediately). To cancel the request return false.

WARNING: This method is deprecated. Use Open instead.

◆ Read()

virtual bool CefResourceHandler::Read ( void *  data_out,
int  bytes_to_read,
int &  bytes_read,
CefRefPtr< CefResourceReadCallback callback 
)
inlinevirtual

Read response data.

If data is available immediately copy up to |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of bytes copied, and return true. To read the data at a later time keep a pointer to |data_out|, set |bytes_read| to 0, return true and execute |callback| when the data is available (|data_out| will remain valid until the callback is executed). To indicate response completion set |bytes_read| to 0 and return false. To indicate failure set |bytes_read| to < 0 (e.g. -2 for ERR_FAILED) and return false. This method will be called in sequence but not from a dedicated thread. For backwards compatibility set |bytes_read| to -1 and return false and the ReadResponse method will be called.

Reimplemented in CefStreamResourceHandler.

◆ ReadResponse()

virtual bool CefResourceHandler::ReadResponse ( void *  data_out,
int  bytes_to_read,
int &  bytes_read,
CefRefPtr< CefCallback callback 
)
inlinevirtual

Read response data.

If data is available immediately copy up to |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of bytes copied, and return true. To read the data at a later time set |bytes_read| to 0, return true and call CefCallback::Continue() when the data is available. To indicate response completion return false.

WARNING: This method is deprecated. Use Skip and Read instead.

◆ Skip()

virtual bool CefResourceHandler::Skip ( int64  bytes_to_skip,
int64 bytes_skipped,
CefRefPtr< CefResourceSkipCallback callback 
)
inlinevirtual

Skip response data when requested by a Range header.

Skip over and discard |bytes_to_skip| bytes of response data. If data is available immediately set |bytes_skipped| to the number of bytes skipped and return true. To read the data at a later time set |bytes_skipped| to 0, return true and execute |callback| when the data is available. To indicate failure set |bytes_skipped| to < 0 (e.g. -2 for ERR_FAILED) and return false. This method will be called in sequence but not from a dedicated thread.


The documentation for this class was generated from the following file: