Bug 46092 - Web Inspector: display headers actually used by network stack in Resources tab
Summary: Web Inspector: display headers actually used by network stack in Resources tab
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Andrey Kosyakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-20 08:02 PDT by Andrey Kosyakov
Modified: 2010-09-30 23:50 PDT (History)
11 users (show)

See Also:


Attachments
proposed patch (19.89 KB, patch)
2010-09-20 09:13 PDT, Andrey Kosyakov
no flags Details | Formatted Diff | Diff
patch (19.86 KB, patch)
2010-09-20 09:32 PDT, Andrey Kosyakov
no flags Details | Formatted Diff | Diff
patch (19.44 KB, patch)
2010-09-20 10:13 PDT, Andrey Kosyakov
pfeldman: review-
Details | Formatted Diff | Diff
patch (20.18 KB, patch)
2010-09-29 06:18 PDT, Andrey Kosyakov
pfeldman: review-
Details | Formatted Diff | Diff
patch (24.60 KB, patch)
2010-09-29 09:23 PDT, Andrey Kosyakov
no flags Details | Formatted Diff | Diff
patch to land (26.33 KB, patch)
2010-09-29 11:28 PDT, Andrey Kosyakov
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Kosyakov 2010-09-20 08:02:05 PDT
Currently, the request and response headers Web Inspector displays in resource tab do not match those actually send over wire:
- for request headers, headers added by the platform network stack are missing. This includes Cookie:, Accept-*: and Cache-Control: headers;
- for response, this includes Set-Cookie header.
It is suggested to provide a way for network stack to return raw headers as part of ResouceResponse, conditionally on a flag set in request.
Comment 1 Andrey Kosyakov 2010-09-20 09:13:14 PDT
Created attachment 68093 [details]
proposed patch
Comment 2 WebKit Review Bot 2010-09-20 09:18:45 PDT
Attachment 68093 [details] did not pass style-queue:

Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1
WebKit/chromium/public/WebResourceRawHeaders.h:38:  Code inside a namespace should not be indented.  [whitespace/indent] [4]
WebKit/chromium/public/WebResourceRawHeaders.h:38:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
WebKit/chromium/public/WebResourceRawHeaders.h:39:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
WebKit/chromium/public/WebResourceRawHeaders.h:80:  Could not find a newline character at the end of the file.  [whitespace/ending_newline] [5]
Total errors found: 4 in 16 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Timothy Hatcher 2010-09-20 09:26:10 PDT
Comment on attachment 68093 [details]
proposed patch

If this is Chromium only, please file a bug about it needed to be implemeneted for other ports. Or find a way to make it work for everyone.
Comment 4 Andrey Kosyakov 2010-09-20 09:32:30 PDT
Created attachment 68096 [details]
patch

Fixed style.
Comment 5 WebKit Review Bot 2010-09-20 09:33:54 PDT
Attachment 68096 [details] did not pass style-queue:

Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1
WebKit/chromium/public/WebResourceRawHeaders.h:38:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 1 in 16 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Ilya Tikhonovsky 2010-09-20 09:34:52 PDT
> WebCore/ChangeLog:8
> +        No new tests. (OOPS!)

nit: please delete this line.

> WebKit/chromium/src/WebResourceRawHeaders.cpp:49
> +    delete m_requestHeaders;
> +    delete m_responseHeaders;

It'd be better to use OwnPtr for these members.

> WebKit/chromium/src/WebResourceRawHeaders.cpp:76
> +    pair<HTTPHeaderMap::iterator, bool> result =
> +        m_private->add(name, value);

Line wrapping doesn't necessary here.

> WebKit/chromium/src/WebURLResponsePrivate.h:60
> +        delete m_resourceRawHeaders;

Can we use OwnPtr here too?
Comment 7 Andrey Kosyakov 2010-09-20 10:13:05 PDT
Created attachment 68104 [details]
patch

- Fixed style again
- Switched to OwnPtr in WebURLResponsePrivate
Comment 8 Andrey Kosyakov 2010-09-20 10:14:48 PDT
(In reply to comment #6)
> > WebCore/ChangeLog:8
> > +        No new tests. (OOPS!)
> 
> nit: please delete this line.

Done.

> > WebKit/chromium/src/WebResourceRawHeaders.cpp:49
> > +    delete m_requestHeaders;
> > +    delete m_responseHeaders;
> 
> It'd be better to use OwnPtr for these members.

Can't do it here -- the WebResourceRawHeaders belongs to WebKit public interface, we can't expose internal WebCore types there.
> 
> > WebKit/chromium/src/WebResourceRawHeaders.cpp:76
> > +    pair<HTTPHeaderMap::iterator, bool> result =
> > +        m_private->add(name, value);
> 
> Line wrapping doesn't necessary here.

Fixed.

> 
> > WebKit/chromium/src/WebURLResponsePrivate.h:60
> > +        delete m_resourceRawHeaders;
> 
> Can we use OwnPtr here too?

Fixed.
Comment 9 WebKit Review Bot 2010-09-20 11:35:15 PDT
Attachment 68093 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/4054090
Comment 10 Pavel Feldman 2010-09-20 23:23:24 PDT
Comment on attachment 68104 [details]
patch

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

A bunch of nits, otherwise looks good.

> WebCore/inspector/InspectorResource.cpp:180
> +        m_responseHeaderFields = headers->responseHeaders;

Either mark request as changed here or modify WebInspector.updateResource to re-read request headers from the payload upon response change.

> WebCore/platform/network/ResourceResponseBase.h:117
> +    PassRefPtr<ResourceRawHeaders> resourceRawHeaders() const;

There is a number of header-related methods (get / set individual headers) that are not going to affect raw headers. So we add a bit of confusion here. Maybe we should push raw headers straight into the inspector controller. Did you track usages of these methods?

> WebKit/chromium/public/WebResourceRawHeaders.h:47
> +class WebResourceRawHeaders {

1. We should do WebResourceHeadersMap I guess and have separate setters in the WebURLRequest
2. Interestingly, we are using headers visitors in the rest of the places. We should talk to the authors of that code to find out why. Are we hesitant copying those for the performance reasons?

> WebKit/chromium/public/WebResourceRawHeaders.h:58
> +        WebCore::HTTPHeaderMap* m_private;

You should use WebPrivatePtr when wrapping WebCore. See the pattern in WebURLLoadTiming.

> WebKit/chromium/public/WebURLResponse.h:86
> +    WEBKIT_API WebResourceRawHeaders* resourceRawHeaders();

Must have a setter here.

> WebKit/chromium/src/WebDevToolsAgentImpl.cpp:328
> +        if (ic->hasFrontend() && request.reportLoadTiming())

I think ic->willSendRequest will do this for you.

> WebKit/chromium/src/WebURLResponsePrivate.h:49
> +    OwnPtr<WebResourceRawHeaders> m_resourceRawHeaders;

Why hiding public WebKit API field here? In fact, we don't need it at all. You should serve both getter and a setter against corresponding ResourceResponse's fields.
Comment 11 Andrey Kosyakov 2010-09-29 06:18:40 PDT
Created attachment 69186 [details]
patch
Comment 12 WebKit Review Bot 2010-09-29 06:21:52 PDT
Attachment 69186 [details] did not pass style-queue:

Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1
WebKit/chromium/public/WebResourceRawHeaders.h:52:  One or more unexpected \r (^M) found; better to use only a \n  [whitespace/carriage_return] [1]
Suppressing further [whitespace/carriage_return] reports for this file.
WebKit/chromium/src/WebResourceRawHeaders.cpp:83:  One or more unexpected \r (^M) found; better to use only a \n  [whitespace/carriage_return] [1]
Suppressing further [whitespace/carriage_return] reports for this file.
WebKit/chromium/src/WebResourceRawHeaders.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
WebKit/chromium/src/WebResourceRawHeaders.cpp:42:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 11 in 16 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Pavel Feldman 2010-09-29 06:42:05 PDT
Comment on attachment 69186 [details]
patch

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

> WebKit/chromium/public/WebResourceRawHeaders.h:37
> +namespace WebCore {

#if WEBKIT_IMPLEMENTATION

> WebKit/chromium/public/WebResourceRawHeaders.h:62
> +        WebCore::HTTPHeaderMap* m_private;

Please use generic WebPrivatePtr instead.

> WebKit/chromium/public/WebURLResponse.h:87
> +    WEBKIT_API WebResourceRawHeaders* resourceRawHeaders();

setter, please

> WebKit/chromium/public/WebURLResponse.h:176
> +    WebPrivateOwnPtr<WebResourceRawHeaders> m_resourceRawHeaders;

WebPrivateOwnPtr is used to map to WebCore, you are simply pointing to public WebKit api class here.
Comment 14 Andrey Kosyakov 2010-09-29 09:23:52 PDT
Created attachment 69201 [details]
patch
Comment 15 WebKit Review Bot 2010-09-29 09:29:32 PDT
Attachment 69201 [details] did not pass style-queue:

Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1
WebKit/chromium/src/WebResourceRawHeaders.cpp:35:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 21 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 16 Pavel Feldman 2010-09-29 10:18:17 PDT
Comment on attachment 69201 [details]
patch

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

> WebCore/WebCore.vcproj/WebCore.vcproj:27431
> +					RelativePath="..\platform\network\ResourceRawHeaders.h"

You should add new files to Xcode project.

> WebKit/chromium/public/WebResourceRawHeaders.h:38
> +class ResourceResponse;

mind import order.

> WebKit/chromium/public/WebResourceRawHeaders.h:50
> +    class HeadersMap {

Having addRequestHeader and addResponseHeader would look much more elegant.

> WebKit/chromium/public/WebResourceRawHeaders.h:62
> +    private:

remove this line.

> WebKit/chromium/src/WebResourceRawHeaders.cpp:79
> +    m_private->responseHeaders = *(const WebCore::HTTPHeaderMap*)value;

Can you do static cast here?
Comment 17 Andrey Kosyakov 2010-09-29 11:28:17 PDT
Created attachment 69230 [details]
patch to land
Comment 18 Eric Seidel (no email) 2010-09-30 03:21:54 PDT
Comment on attachment 69201 [details]
patch

Cleared Pavel Feldman's review+ from obsolete attachment 69201 [details] so that this bug does not appear in http://webkit.org/pending-commit.
Comment 19 Andrey Kosyakov 2010-09-30 23:50:52 PDT
Committed manually as r68781: http://trac.webkit.org/changeset/68781
Committed build fix as r68783: http://trac.webkit.org/changeset/68783