[Webkit-unassigned] [Bug 111574] New: [WK2][GTK] Invalid request returned by webkit_download_get_request if called before download starts

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Mar 6 06:30:12 PST 2013


https://bugs.webkit.org/show_bug.cgi?id=111574

           Summary: [WK2][GTK] Invalid request returned by
                    webkit_download_get_request if called before download
                    starts
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: Unspecified
        OS/Version: Unspecified
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: WebKit Gtk
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: rego at igalia.com
                CC: xan.lopez at gmail.com, mrobinson at webkit.org,
                    cgarcia at igalia.com


The following code will return an invalid request:

    WebKitDownload* download = webkit_web_context_download_uri(webkit_web_context_get_default(), "http://www.google.com/");
    WebKitURIRequest* request = webkit_download_get_request(download);
    // Request is invalid here, for example next method will return an empty string
    webkit_uri_request_get_uri(request); // Empty instead of "http://www.google.com/"

However, if you wait till download stats, the request is valid and the method webkit_uri_request_get_uri() works properly.

Taking a look to the related code:

* WebKitDownload.cpp:

WebKitURIRequest* webkit_download_get_request(WebKitDownload* download)
{
    g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0);

    WebKitDownloadPrivate* priv = download->priv;
    if (!priv->request)
        priv->request = adoptGRef(webkitURIRequestCreateForResourceRequest(priv->download->request()));
    return priv->request.get();
}

* DownloadProxy.h:

    const WebCore::ResourceRequest& request() const { return m_request; }

* DownloadProxy.cpp:

void DownloadProxy::didStart(const ResourceRequest& request)
{
    m_request = request;

    if (!m_webContext)
        return;

    m_webContext->downloadClient().didStart(m_webContext.get(), this);
}

In WebKitDownload priv->download is a DownloadProxy. So, if it's called before DownloadProxy::didStart the request is not initialized yet.

There's even a bigger problem in webkit_download_get_request, as it's caching the request in priv->request. If you call webkit_download_get_request before didStart (like in the example above) and you call it again after didStart, it's going to return always an invalid request.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list