Bug 72946 - [GTK] Add WebKitURIResponse to WebKit2 GTK+ API
Summary: [GTK] Add WebKitURIResponse to WebKit2 GTK+ API
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on:
Blocks: 72949
  Show dependency treegraph
 
Reported: 2011-11-22 05:59 PST by Carlos Garcia Campos
Modified: 2011-11-29 03:11 PST (History)
5 users (show)

See Also:


Attachments
Patch (16.31 KB, patch)
2011-11-22 06:11 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch (18.14 KB, patch)
2011-11-28 06:37 PST, Carlos Garcia Campos
mrobinson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2011-11-22 05:59:49 PST
It will be needed by Download and Policy clients.
Comment 1 Carlos Garcia Campos 2011-11-22 06:11:08 PST
Created attachment 116213 [details]
Patch

It only returns uri, content_length and status_code for now. It doesn't include unit tests, because it will be covered by other unit tests like downloads and policy client.
Comment 2 WebKit Review Bot 2011-11-22 06:21:41 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 3 Martin Robinson 2011-11-23 02:10:18 PST
Comment on attachment 116213 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=116213&action=review

> Source/WebKit2/UIProcess/API/gtk/WebKitNetworkResponse.cpp:130
> + * the server. It will normally be a #SoupKnownStatusCode, eg,
> + * %SOUP_STATUS_OK, though of course it might actually be an unknown
> + * status code.

I would rephrase this slightly to: It will normally be a #SoupKnownStatusCode, for example %SOUP_STATUS_OK, though the server can respond with any unsigned integer. We need to look into how we can properly link to soup documentation so this doesn't produce errors during the gktdoc-fixxref run.

> Source/WebKit2/UIProcess/API/gtk/WebKitNetworkResponse.cpp:153
> +guint64 webkit_network_response_get_content_length(WebKitNetworkResponse* response)

Any reason this isn't a property? It is appropriate to use gsize here instead of guint64? Soup seems to use goffset, which I assume is the same data type as gsize.

> Source/WebKit2/UIProcess/API/gtk/WebKitNetworkResponse.cpp:170
> +    WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "uri", uri.get(), NULL));

Ah, is this why you've chosen to use a property for uri, but not the others? I guess I would prefer that all private data be properties or none of them.

> Source/WebKit2/UIProcess/API/gtk/WebKitNetworkResponse.cpp:176
> +SoupMessage*
> +webkitNetworkResponseGetSoupMessage(WebKitNetworkResponse* response)

Extra newline here. :)
Comment 4 Carlos Garcia Campos 2011-11-23 07:58:14 PST
(In reply to comment #3)
> (From update of attachment 116213 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=116213&action=review
> 
> > Source/WebKit2/UIProcess/API/gtk/WebKitNetworkResponse.cpp:130
> > + * the server. It will normally be a #SoupKnownStatusCode, eg,
> > + * %SOUP_STATUS_OK, though of course it might actually be an unknown
> > + * status code.
> 
> I would rephrase this slightly to: It will normally be a #SoupKnownStatusCode, for example %SOUP_STATUS_OK, though the server can respond with any unsigned integer. 

I copied it literally from the libsoup api docs :-P

> We need to look into how we can properly link to soup documentation so this doesn't produce errors during the gktdoc-fixxref run.

Right.

> > Source/WebKit2/UIProcess/API/gtk/WebKitNetworkResponse.cpp:153
> > +guint64 webkit_network_response_get_content_length(WebKitNetworkResponse* response)
> 
> Any reason this isn't a property? It is appropriate to use gsize here instead of guint64? Soup seems to use goffset, which I assume is the same data type as gsize.

Because data length used by WebKit2 internal API is uint64_t

> > Source/WebKit2/UIProcess/API/gtk/WebKitNetworkResponse.cpp:170
> > +    WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "uri", uri.get(), NULL));
> 
> Ah, is this why you've chosen to use a property for uri, but not the others? I guess I would prefer that all private data be properties or none of them.

Yes, because it's construct only.

> > Source/WebKit2/UIProcess/API/gtk/WebKitNetworkResponse.cpp:176
> > +SoupMessage*
> > +webkitNetworkResponseGetSoupMessage(WebKitNetworkResponse* response)
> 
> Extra newline here. :)

Ok.
Comment 5 Dan Winship 2011-11-24 07:37:47 PST
(In reply to comment #4)
> > We need to look into how we can properly link to soup documentation so this doesn't produce errors during the gktdoc-fixxref run.

I think if you have the libsoup gtk-docs installed in the prefix you are installing webkit into, it will find them automatically.

> > > +guint64 webkit_network_response_get_content_length(WebKitNetworkResponse* response)
> > 
> > Any reason this isn't a property? It is appropriate to use gsize here instead of guint64? Soup seems to use goffset, which I assume is the same data type as gsize.

(Not always. gsize is size_t and goffset is offset_t. On x86_64 they're both 64-bit but on x86 size_t is 32-bit.)

> > Ah, is this why you've chosen to use a property for uri, but not the others? I guess I would prefer that all private data be properties or none of them.
> 
> Yes, because it's construct only.

Having properties for everything is more language-bindings-friendly.
Comment 6 Martin Robinson 2011-11-24 07:42:55 PST
(In reply to comment #5)

> Having properties for everything is more language-bindings-friendly.

In this case, I think it makes sense to have all members be properties or none of them, but not only some of them.
Comment 7 Carlos Garcia Campos 2011-11-24 07:48:35 PST
(In reply to comment #6)
> (In reply to comment #5)
> 
> > Having properties for everything is more language-bindings-friendly.
> 
> In this case, I think it makes sense to have all members be properties or none of them, but not only some of them.

Good point, I agree, I'll update the wiki accordingly http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API

btw, I'll rename this and NetworkRequest as WebKitURIRequest/Response if nobody objects.
Comment 8 Martin Robinson 2011-11-24 07:51:16 PST
(In reply to comment #7)

> btw, I'll rename this and NetworkRequest as WebKitURIRequest/Response if nobody objects.

I like WebKitURIRequest. It's more accurate and less typing. :)
Comment 9 Carlos Garcia Campos 2011-11-28 06:37:05 PST
Created attachment 116749 [details]
Updated patch

Updated according to review comments and renamed to WebKitURIResponse
Comment 10 Martin Robinson 2011-11-28 11:23:30 PST
Comment on attachment 116749 [details]
Updated patch

View in context: https://bugs.webkit.org/attachment.cgi?id=116749&action=review

Nice.

> Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp:98
> +     * The URI to which the response will be made.

Maybe change this to "The URI for which the response was made."

> Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp:104
> +                                                        _("The URI to which the response will be made."),

Ditto.

> Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp:182
> + * be 0 if the server provided incorrect or missing Content-Length.

You have "an" after provided.
Comment 11 Carlos Garcia Campos 2011-11-29 03:11:14 PST
Committed r101350: <http://trac.webkit.org/changeset/101350>