Skip to content

Latest commit

 

History

History
123 lines (84 loc) · 3.9 KB

WebRequest.md

File metadata and controls

123 lines (84 loc) · 3.9 KB

API categories | API index

WebRequest (class)

Table of contents:

Preface

You cannot instantiate the WebRequest class directly, use its static method instead by calling cefpython.WebRequest.Create().

Class used to make a URL request. URL requests are not associated with a browser instance so no client handler callbacks will be executed. URL requests can be created on any valid CEF thread in either the browser or render process. Once created the methods of the URL request object must be accessed on the same thread that created it.

The WebRequest example can be found in the wxpython-response.py script on Linux.

TODO: get rid of the static method WebRequest.Create by swapping objects using the __new__() method, see: https://stackoverflow.com/questions/3209233

Methods

Create

Parameter Type
request Request
handler WebRequestClient
Return static WebRequest

Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request methods are supported. Multiple post data elements are not supported and elements of type PDE_TYPE_FILE are only supported for requests originating from the browser process. Requests originating from the render process will receive the same handling as requests originating from Web content -- if the response contains Content-Disposition or Mime-Type header values that would not normally be rendered then the response may receive special handling inside the browser (for example, via the file download code path instead of the URL request code path). The |request| object will be marked as read-only after calling this method. In the browser process if |request_context| is empty the global request context will be used. In the render process |request_context| must be empty and the context associated with the current renderer process' browser will be used.

The first parameter is a Request object that needs to be created by calling cefpython.Request.CreateRequest().

The WebRequestClient handler is a python class that implements the WebRequestClient callbacks.

IMPORTANT: You must keep a strong reference to the [WebRequest](WebRequest .md) object during the request, otherwise it gets destroyed and the WebRequestClient callbacks won't get called.

GetRequest

Return Request

Returns the request object used to create this URL request. The returned object is read-only and should not be modified.

GetRequestStatus

Return RequestStatus

Returns the request status. RequestStatus can be one of:

cefpython.WebRequest.Status["Unknown"] - Unknown status.
cefpython.WebRequest.Status["Success"] - Request succeeded.
cefpython.WebRequest.Status["Pending"] - An IO request is pending, and the caller will be informed when it is completed.
cefpython.WebRequest.Status["Canceled"] - Request was canceled programatically.
cefpython.WebRequest.Status["Failed"] - Request failed for some reason.

GetRequestError

Return NetworkError

Returns the request error if status is "Canceled" or "Failed", or 0
otherwise.

GetResponse

Return Response

Returns the response, or None if no response information is available.
Response information will only be available after the upload has completed.
The returned object is read-only and should not be modified.

Cancel

Return void

Cancel the request.