WebResourceRequest

Since: BlackBerry 10.0.0

#include <bb/cascades/WebResourceRequest>

A resource being requested by a WebView.

The class provides you with the URL for the resource request.

For advanced use cases, the WebResourceRequestFilter can chose to substitute a response to the request, thus bypassing the network stack. In that case, the implementation must call notifyOpen() exactly once, notifyHeaderReceived() any amount of times, notifyDataRecieved() any amount of times and finally notifyDone() exactly once.


Overview

Properties Index

QUrlurl [read-only]

Public Functions Index

WebResourceRequest (WebResourceRequestPrivate *dd_ptr, QObject *parent=0)
virtual ~WebResourceRequest ()
QByteArraybody () const
QUrlreferrer () const
QUrlurl () const

Public Slots Index

voidnotifyDataReceived (const QByteArray &data)
voidnotifyDone ()
voidnotifyHeaderReceived (const QString &key, const QString &value)
voidnotifyOpen (int statusCode, const QString &message)

Properties

QUrl url[read-only]

The URL of the resource requested.

Since:

BlackBerry 10.0.0

Public Functions

WebResourceRequest (
  • WebResourceRequestPrivate *dd_ptr,
  • QObject *parent )

Constructs a WebResourceRequest.

Since:

BlackBerry 10.0.0

virtual~WebResourceRequest ()

Destructor.

QByteArray body ()

Returns the body of the request.

The only time this will not be empty is when called during filterResourceRequest(), and even then it will likely be empty unless the request is a FormSubmission. Once the FilterAction is returned, the body is no longer available. Calling this method after that time is guaranteed to return an empty QByteArray().

The QByteArray returned is created using QByteArray::fromRawData to reduce the initial memory cost, however this means that the QByteArray is not guaranteed to be valid after filterResourceRequest returns. The body should be copied to another QByteArray object if it is needed after that time.

Since:

BlackBerry 10.0.0

QUrl referrer ()

Returns the referrer of the resource requested.

Note: Due to an unfortunate misspelling in the original specification, the referrer is actually misspelled "Referer" in HTTP headers.

Since:

BlackBerry 10.0.0

QUrl url ()

Returns the URL of the resource requested.

Since:

BlackBerry 10.0.0

Public Slots

void notifyDataReceived (

Provides a response for this request, indicating status code and message.

This can be called by a WebResourceRequestFilter implementation that has returned WebResourceRequestFilter::Substitute from WebResourceRequestFilter::filterResourceRequest().

Parameters
data

The data.

Since:

BlackBerry 10.0.0

void notifyDone ()

Notifies the browser engine that the WebResourceRequestFilter implementation is done substituting this request.

This can be called by a WebResourceRequestFilter implementation that has returned WebResourceRequestFilter::Substitute from WebResourceRequestFilter::filterResourceRequest().

Call this after providing all headers and data for the request.

Since:

BlackBerry 10.0.0

void notifyHeaderReceived (

Provides a response for this request, indicating status code and message.

This can be called by a WebResourceRequestFilter implementation that has returned WebResourceRequestFilter::Substitute from WebResourceRequestFilter::filterResourceRequest().

Parameters
key

The key for this header.

value

The value for this header.

Since:

BlackBerry 10.0.0

void notifyOpen (
  • intstatusCode,
  • const QString &message )

Provides a response for this request, indicating status code and message.

This can be called by a WebResourceRequestFilter implementation that has returned WebResourceRequestFilter::Substitute from WebResourceRequestFilter::filterResourceRequest().

Parameters
statusCode

The HTTP status code.

message

A message.

Since:

BlackBerry 10.0.0

Last modified: 2014-09-29



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus