Bug 37274 - Report resource URL and error details in resource events
Summary: Report resource URL and error details in resource events
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh OS X 10.5
: P4 Minor
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-08 08:01 PDT by Andrey Kosyakov
Modified: 2010-04-09 15:43 PDT (History)
2 users (show)

See Also:


Attachments
Fixed ResourceError::failingURL() and ResourceResponse::httpStatusText() to return meaningful values (3.62 KB, patch)
2010-04-08 08:05 PDT, Andrey Kosyakov
no flags Details | Formatted Diff | Diff
Fixed ResourceError::failingURL() and ResourceResponse::httpStatusText() to return meaningful values (4.29 KB, patch)
2010-04-08 08:18 PDT, Andrey Kosyakov
no flags Details | Formatted Diff | Diff
Fixed ResourceError::failingURL() and ResourceResponse::httpStatusText() to return meaningful values (style fixed) (4.27 KB, patch)
2010-04-09 10:36 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-04-08 08:01:05 PDT
When resource loader reports resource events, the following methods return unexpected values:

- ResourceError::failingURL() is always empty
- ResourceResponse::httpStatusText() is always "OK"
Comment 1 Andrey Kosyakov 2010-04-08 08:05:58 PDT
Created attachment 52866 [details]
Fixed ResourceError::failingURL() and ResourceResponse::httpStatusText() to return meaningful values
Comment 2 Andrey Kosyakov 2010-04-08 08:11:31 PDT
Comment on attachment 52866 [details]
Fixed ResourceError::failingURL() and ResourceResponse::httpStatusText() to return meaningful values

One of changed test expectations was accidently missing from patch, about to commit another one in a few minutes.
Comment 3 Andrey Kosyakov 2010-04-08 08:18:45 PDT
Created attachment 52868 [details]
Fixed ResourceError::failingURL() and ResourceResponse::httpStatusText() to return meaningful values
Comment 4 Darin Adler 2010-04-08 11:57:02 PDT
Comment on attachment 52868 [details]
Fixed ResourceError::failingURL() and ResourceResponse::httpStatusText() to return meaningful values

> +    m_failingURL = failingURLString; 

Good fix. Where's the test case for this, though? It's separate from the other fix. We don't take bug fixes without test cases.

> -        // FIXME: it would be nice to have a way to get the real status text eventually.
> -        m_httpStatusText = "OK";
> +        // we used to return "OK" for everything, so be compatible and return "OK" for 200.
> +        m_httpStatusText = m_httpStatusCode == 200 ? String("OK") 
> +                                                   : String([NSHTTPURLResponse localizedStringForStatusCode: m_httpStatusCode]);

Does the localizedStringForStatusCode method exist on all platforms we build on? Tiger?

Formatting here is wrong -- we normally don't indent the second line of a conditional expression like this. We just indent by a single tab stop.

What does [NSHTTPURLResponse localizedStringForStatusCode:] return for 200? Do we really need the hard-coded string?
Comment 5 Andrey Kosyakov 2010-04-09 10:31:29 PDT
(In reply to comment #4)
> (From update of attachment 52868 [details])
> > +    m_failingURL = failingURLString; 
> 
> Good fix. Where's the test case for this, though? It's separate from the other
> fix. We don't take bug fixes without test cases.

There's a bit of a problem with testing for this -- currently, resource notification related code in DumpRenderTree is platform-specific (DumpRenderTree/mac/ResourceLoadDelegate.mm) and uses native platform classes (NSError & co) only -- the classes that I changed are not used at all. Adding tests for them at this level would require implementing tests explicitly for different platforms, plus passing additional flags via LayoutTestsController. A much cheaper and practical solution would be to test it on a higher level -- e.g. in inspector tests, as my initial motivation for fixing this was to enable logging of messages to inspector console in case of resource loading problems. This will also cover all platforms at once. This requires, however, that the patch for logging resource errors to inspector is landed (http://webkit.org/b/37215), so I added the test there. In will only pass once both this and 37215 are landed, though.
 
> > -        // FIXME: it would be nice to have a way to get the real status text eventually.
> > -        m_httpStatusText = "OK";
> > +        // we used to return "OK" for everything, so be compatible and return "OK" for 200.
> > +        m_httpStatusText = m_httpStatusCode == 200 ? String("OK") 
> > +                                                   : String([NSHTTPURLResponse localizedStringForStatusCode: m_httpStatusCode]);
> 
> Does the localizedStringForStatusCode method exist on all platforms we build
> on? Tiger?

At least the manual says so (http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSHTTPURLResponse_Class/Reference/Reference.html):

Return Value
A localized string suitable for displaying to users that describes the specified status code.

Availability
Available in Mac OS X v10.2 with Safari 1.0 installed.
Available in Mac OS X v10.2.7 and later.

> 
> Formatting here is wrong -- we normally don't indent the second line of a
> conditional expression like this. We just indent by a single tab stop.

Fixed!

> What does [NSHTTPURLResponse localizedStringForStatusCode:] return for 200? Do
> we really need the hard-coded string?

localizedStringForStatusCode returns "no error". I don't have an evidence that we really need this hack (except for a handful of tests that would need to be re-baselined as a result of this), but considering this value is made available to JS via XMLHttpRequest.statusText, I'd rather be on a safe side and leave it as it used to be in cases where it doesn't contradict numeric value (especially given that OK is what HTTP/1.1 suggests for 200).
Comment 6 Andrey Kosyakov 2010-04-09 10:36:37 PDT
Created attachment 52967 [details]
Fixed ResourceError::failingURL() and ResourceResponse::httpStatusText() to return meaningful values (style fixed)
Comment 7 WebKit Commit Bot 2010-04-09 13:01:27 PDT
Comment on attachment 52967 [details]
Fixed ResourceError::failingURL() and ResourceResponse::httpStatusText() to return meaningful values (style fixed)

Clearing flags on attachment: 52967

Committed r57351: <http://trac.webkit.org/changeset/57351>
Comment 8 WebKit Commit Bot 2010-04-09 13:01:31 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Alexey Proskuryakov 2010-04-09 15:43:33 PDT
I don't think it's a good idea to synthesize status text - if someone actually needs to look at it, they won't appreciate us lying.

Fortunately, there was a way to fix this long-standing issue, see bug 24572.