WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 152022
REGRESSION (
r192796
) WKBundlePageResourceLoadClient should be able to setHTTPBody in willSendRequestForFrame
https://bugs.webkit.org/show_bug.cgi?id=152022
Summary
REGRESSION (r192796) WKBundlePageResourceLoadClient should be able to setHTTP...
Alex Christensen
Reported
2015-12-08 16:01:19 PST
REGRESSION (
r192796
) WKBundlePageResourceLoadClient should be able to setHTTPBody in willSendRequestForFrame
Attachments
Patch
(1.82 KB, patch)
2015-12-08 16:03 PST
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(1.86 KB, patch)
2015-12-08 18:31 PST
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(1.98 KB, patch)
2015-12-09 10:45 PST
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(11.63 KB, patch)
2015-12-09 13:45 PST
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews103 for mac-yosemite
(1.07 MB, application/zip)
2015-12-09 14:24 PST
,
Build Bot
no flags
Details
Patch
(12.98 KB, patch)
2015-12-09 14:49 PST
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(13.95 KB, patch)
2015-12-10 10:41 PST
,
Alex Christensen
darin
: review+
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Alex Christensen
Comment 1
2015-12-08 16:03:53 PST
Created
attachment 266949
[details]
Patch
Alex Christensen
Comment 2
2015-12-08 18:21:39 PST
rdar://problem/23763584
Alex Christensen
Comment 3
2015-12-08 18:31:11 PST
Created
attachment 266960
[details]
Patch
Alexey Proskuryakov
Comment 4
2015-12-08 21:01:12 PST
Comment on
attachment 266960
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=266960&action=review
> Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp:53 > - request.updateFromDelegatePreservingOldProperties(returnedRequest->resourceRequest()); > + request = returnedRequest->resourceRequest();
I don't think that we can do this, it will make us drop everything from the request that cannot be round-tripped via an NSURLRequest.
Alex Christensen
Comment 5
2015-12-09 10:45:22 PST
Created
attachment 267021
[details]
Patch
Alexey Proskuryakov
Comment 6
2015-12-09 10:48:26 PST
Comment on
attachment 267021
[details]
Patch Looks good to me; r- since you are still working on a test.
Alex Christensen
Comment 7
2015-12-09 13:45:00 PST
Created
attachment 267042
[details]
Patch
Build Bot
Comment 8
2015-12-09 14:24:11 PST
Comment on
attachment 267042
[details]
Patch
Attachment 267042
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.webkit.org/results/538383
New failing tests: http/tests/misc/will-send-request-http-body.html
Build Bot
Comment 9
2015-12-09 14:24:14 PST
Created
attachment 267046
[details]
Archive of layout-test-results from ews103 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews103 Port: mac-yosemite Platform: Mac OS X 10.10.5
Alex Christensen
Comment 10
2015-12-09 14:38:28 PST
Oops, forgot WK1
Alex Christensen
Comment 11
2015-12-09 14:49:09 PST
Created
attachment 267047
[details]
Patch
Alexey Proskuryakov
Comment 12
2015-12-09 17:05:44 PST
Comment on
attachment 267047
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=267047&action=review
> Source/WebKit2/Shared/API/c/WKURLRequest.cpp:62 > +WKURLRequestRef WKURLRequestWithHTTPBody(WKURLRequestRef requestRef, WKDataRef body)
This function returns a retained object, so it should be named appropriately.
> Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp:54 > + RefPtr<FormData> returnedHTTPBody = returnedResourceRequest.httpBody();
What happens if the client tries to set a body stream? That can't work with NetworkProcess, so we should make sure that we fail cleanly (maybe CRASH()?)
> Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:1175 > + WKRetain(requestWithBody);
This retains it again, so I bet that there is a memory leak.
> Tools/WebKitTestRunner/InjectedBundle/TestRunner.h:215 > + void setWillSendRequestHTTPBody(JSStringRef body) { m_willSendRequestHTTPBody = toWTFString(toWK(body)); }
This is not consistent with the naming of functions above. Maybe something like setWillSendRequestAddsHTTPBody?
> LayoutTests/ChangeLog:3 > + REGRESSION (
r192796
) WKBundlePageResourceLoadClient should be able to setHTTPBody in willSendRequestForFrame
Can we also test what happens when the request already has a body, and the client sets it anyway.
> LayoutTests/ChangeLog:9 > + * http/tests/misc/resources/post-echo.cgi: Copied from http/tests/misc/resources/post-echo-and-notify-done.cgi.
Can we move http/tests/xmlhttprequest/resources/post-echo.cgi?
> LayoutTests/TestExpectations:47 > +http/tests/misc/will-send-request-http-body.html [ Skip ]
will-send-request-with-client-provided-http-body.html ?
Darin Adler
Comment 13
2015-12-09 19:28:39 PST
Comment on
attachment 267047
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=267047&action=review
>> Source/WebKit2/Shared/API/c/WKURLRequest.cpp:62 >> +WKURLRequestRef WKURLRequestWithHTTPBody(WKURLRequestRef requestRef, WKDataRef body) > > This function returns a retained object, so it should be named appropriately.
Meaning it needs the word Copy or Create in its name.
Alex Christensen
Comment 14
2015-12-10 10:41:33 PST
Created
attachment 267114
[details]
Patch
Alex Christensen
Comment 15
2015-12-10 10:43:41 PST
I addressed all comments, except http/tests/xmlhttprequest/resources/post-echo.cgi is used by 14 xmlhttprequest tests, so I copied the file rather than change the location of the request in all those tests.
Darin Adler
Comment 16
2015-12-10 11:59:06 PST
Comment on
attachment 267114
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=267114&action=review
> Source/WebKit2/Shared/API/c/WKURLRequest.cpp:65 > + requestCopy.setHTTPBody(FormData::create(WKDataGetBytes(body), WKDataGetSize(body)));
Is there a way to do this without copying the data object?
> Source/WebKit2/Shared/API/c/WKURLRequest.h:45 > +WK_EXPORT WKURLRequestRef WKURLRequestCopyWithHTTPBody(WKURLRequestRef, WKDataRef);
I think maybe it should be named CopySettingHTTPBody. It also seems strange that we are doing this in the C API but not the Objective-C API.
> Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.mm:38 > + if ([urlRequest HTTPBodyStream]) > + CRASH();
This is strange. Is a crash really what we want for this? In Objective-C APIs we use exceptions for this sort of thing.
> Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp:54 > + RefPtr<FormData> returnedHTTPBody = returnedResourceRequest.httpBody();
I think this needs a “why” comment.
> Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp:57 > + request.setHTTPBody(returnedHTTPBody.release());
Can we use WTF::move here?
> Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp:59 > request = ResourceRequest();
Could change this to { } instead of ResourceRequest(), more terse so nice to read.
> Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:1173 > + CString cBody = body.utf8();
This can fail if the string is not valid UTF-16; I think we’d want to handle that case but maybe not if this is just for testing.
> Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:1175 > + WKURLRequestRef requestWithBody = WKURLRequestCopyWithHTTPBody(request, WKDataCreate(reinterpret_cast<const unsigned char*>(cBody.data()), cBody.length())); > + return requestWithBody;
Why the local variable here?
> LayoutTests/http/tests/misc/resources/post-echo.cgi:7 > + read(STDIN, $request, $ENV{'CONTENT_LENGTH'}) > + || die "Could not get query\n";
Would read nicer as a one-liner.
Alex Christensen
Comment 17
2015-12-10 13:24:43 PST
Comment on
attachment 267114
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=267114&action=review
>> Source/WebKit2/Shared/API/c/WKURLRequest.cpp:65 >> + requestCopy.setHTTPBody(FormData::create(WKDataGetBytes(body), WKDataGetSize(body))); > > Is there a way to do this without copying the data object?
Not really right now. This is the only FormData::create that takes raw data. This is just for testing, though.
>> Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.mm:38 >> + CRASH(); > > This is strange. Is a crash really what we want for this? In Objective-C APIs we use exceptions for this sort of thing.
I'll return nullptr.
>> Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:1173 >> + CString cBody = body.utf8(); > > This can fail if the string is not valid UTF-16; I think we’d want to handle that case but maybe not if this is just for testing.
This is just for testing.
>> Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:1175 >> + return requestWithBody; > > Why the local variable here?
Not needed. Will remove.
Alex Christensen
Comment 18
2015-12-10 13:27:00 PST
http://trac.webkit.org/changeset/193924
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug