Bug 109351 - Cache XHRs is not working well
Summary: Cache XHRs is not working well
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-09 03:12 PST by Hyungwook Lee
Modified: 2018-03-21 03:46 PDT (History)
5 users (show)

See Also:


Attachments
patches for 109351 (1.81 KB, patch)
2013-02-09 05:18 PST, Hyungwook Lee
no flags Details | Formatted Diff | Diff
patches for 109351 (1.81 KB, patch)
2013-02-09 05:25 PST, Hyungwook Lee
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hyungwook Lee 2013-02-09 03:12:50 PST
Cache XHRs is not working well as we expected caused by wrong httpBody() comparison.

bool CachedRawResource::canReuse(const ResourceRequest& newRequest) const 
{
...
    if (m_resourceRequest.httpBody() != newRequest.httpBody())
        return false;
...
}

FormData* ResourceRequestBase::httpBody() returns pointer.
Hence we need to compare its value instead of pointer.
Comment 1 Hyungwook Lee 2013-02-09 05:18:09 PST
Created attachment 187425 [details]
patches for 109351
Comment 2 WebKit Review Bot 2013-02-09 05:21:08 PST
Attachment 187425 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/loader/cache/CachedRawResource.cpp']" exit_code: 1
Source/WebCore/loader/cache/CachedRawResource.cpp:183:  Tab found; better to use spaces  [whitespace/tab] [1]
Source/WebCore/loader/cache/CachedRawResource.cpp:184:  Tab found; better to use spaces  [whitespace/tab] [1]
Source/WebCore/loader/cache/CachedRawResource.cpp:186:  Tab found; better to use spaces  [whitespace/tab] [1]
Source/WebCore/loader/cache/CachedRawResource.cpp:187:  Tab found; better to use spaces  [whitespace/tab] [1]
Source/WebCore/loader/cache/CachedRawResource.cpp:189:  Tab found; better to use spaces  [whitespace/tab] [1]
Source/WebCore/loader/cache/CachedRawResource.cpp:190:  Tab found; better to use spaces  [whitespace/tab] [1]
Source/WebCore/loader/cache/CachedRawResource.cpp:191:  Tab found; better to use spaces  [whitespace/tab] [1]
Source/WebCore/loader/cache/CachedRawResource.cpp:192:  Tab found; better to use spaces  [whitespace/tab] [1]
Total errors found: 8 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Hyungwook Lee 2013-02-09 05:25:46 PST
Created attachment 187426 [details]
patches for 109351
Comment 4 Alexey Proskuryakov 2013-02-11 17:44:42 PST
What is the expected behavior when just sending two identical POST requests with XHR? I expect them to be delivered to the server.

Caching POST responses makes sense for back/forward navigation, but probably not for XHR.

So it seems like this mistake was actually resulting in correct behavior.
Comment 5 Hyungwook Lee 2013-02-11 18:44:43 PST
Oh I see,

I got your point and I can understand why it uses pointer instead of value.
Comment 6 Nate Chapin 2013-02-12 08:54:10 PST
(In reply to comment #4)
> What is the expected behavior when just sending two identical POST requests with XHR? I expect them to be delivered to the server.
> 
> Caching POST responses makes sense for back/forward navigation, but probably not for XHR.
> 
> So it seems like this mistake was actually resulting in correct behavior.

For reasons I don't remember, canReuse() permits reuse of POST requests if the new request is POST as well. Should we change it to support GET only?
Comment 7 Alexey Proskuryakov 2013-02-12 10:39:41 PST
> For reasons I don't remember, canReuse() permits reuse of POST requests if the new request is POST as well

Perhaps that's for b/f navigation?
Comment 8 Hyungwook Lee 2013-02-15 05:41:43 PST
I think my patches is not fully considered real world's situation. 
Using cached XHRs (GET/POST both) easily break many web services which uses XHRs to update their web services.