[webkit-qt] Checking the HTTP status code of more than one instance of QWebPage

Alexandre Pretyman alexandre.pretyman at gmail.com
Fri Mar 30 08:40:17 PDT 2012


Hi Jocelyn,

Thanks for answering, but I have indeed gone down that route, with no
results, so I thought it wasn't the right way to go.

I overload virtual bool supportsExtension ( Extension extension ) const;
with:


    qDebug() << "SupportsExtension" << extension;

    return true;



and I overload: virtual bool extension ( Extension extension, const
ExtensionOption * option = 0, ExtensionReturn * output = 0 ); with:

    if (extension == ErrorPageExtension)

    {

        const ErrorPageExtensionOption * errorPageOption =
static_cast<const ErrorPageExtensionOption *>(option);

        qDebug() << "ErrorPageExtensionOption domain:" <<
errorPageOption->domain << " errorString:" <<
errorPageOption->errorString

                    << "error:" << errorPageOption->error << "URL:" <<
errorPageOption->url;

     }

    else // I know the message below is rubbish, it's just to print
something if it gets there

    {

        qDebug() << "Untreated extension:" << extension << " opts: "
<< option << " output: " << output;

    }

    return true;


And 100% positive they don't get called on HTTP status code 408 (for
Operation Timed Out) and I don't remember it being called for HTTP status
code 503 (Service Unavailable) either.

And the only thing I have logged for this is:

   SupportsExtension 1

ErrorPageExtensionOption domain: 0  errorString: "Unknown error" error: 205

Where:

Extension 1 = QWebPage::ErrorPageExtension
domain     0 = QWebPage::QtNetwork
error     205 = QNetworkReply::ContentReSendError


But, as mentioned above, never for 408.

Any other hints?

Regards

On Fri, Mar 30, 2012 at 12:05 PM, Jocelyn Turcotte <
jocelyn.turcotte at nokia.com> wrote:

> Hello list member,
>
> you could have a look at subclassing QWebPage and overriding
> QWebPage::extension and QWebPage::supportsExtension (
> http://qt-project.org/doc/qt-4.8/qwebpage.html#extension ).
>
> Check for QWebPage::ErrorPageExtension and
> ErrorPageExtensionOption::domain == QWebPage::Http and then you can feed an
> appropriate output to ErrorPageExtensionReturn::content from a local file
> or resource.
> This method is intended for providing a custom error page to display, but
> you could also try to handle the error for your app in there.
>
> Worst case you can use different QNetworkAccessManagers, but you might get
> performance issues. Each of them might spawn threads of their own and I
> think that there is no global limit for parallel connections, only
> per-instance, so you might get scaling issues when using more than 5-10 of
> them under heavy load.
>
> br,
> Jocelyn
>
>
> On Fri, 30 Mar 2012 11:44:17 -0300
> ext Alexandre Pretyman <alexandre.pretyman at gmail.com> wrote:
>
> > Hi list,
> >
> > I'm using Qt 4.8 release from QtSDK 1.1.5 and the QtWebKit API that comes
> > with it.
> >
> > I'm checking the HTTP Status of a page loaded in a QWebFrame with code as
> > described in this StackOverflow post:
> >
> http://stackoverflow.com/questions/4330274/qtwebkit-how-to-check-http-status-code
> ,
> > which essentially tells me to connect to
> > SIGNAL(finished(QNetworkReply*))  on the QNetworkAccessManager assiciated
> > with the QWebPage and examine reply->attribute(QNetworkRequest::
> > HttpStatusCodeAttribute) to get the HTTP status code
> >
> > This has been working well since I've been using a single QWebPage, but
> now
> > I need more than one instance of QWebPage running.
> >
> > Since the recommended practice is to have one QNetworkAcessManager per
> > application, if I connect to SIGNAL(finished(QNetworkReply*)) , I
> > understand I'll be getting QNetworkReply * from both instances, and won't
> > be able to differentiate which came from which.
> >
> > How can I overcome this?
> >
> > Regards,
>
>


-- 
Alexandre Pretyman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20120330/e6d1c237/attachment-0001.html>


More information about the webkit-qt mailing list