Skip to content

Commit

Permalink
[webview_flutter_wkwebview] Fix bug of overriding default values of `…
Browse files Browse the repository at this point in the history
…NSURLRequest` (flutter#5969)
  • Loading branch information
bparrishMines authored and yutaaraki-toydium committed Aug 12, 2022
1 parent 873968e commit a1af363
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ - (void)testFWFNSURLRequestFromRequestData {
XCTAssertEqualObjects(request.allHTTPHeaderFields, @{@"a" : @"header"});
}

- (void)testFWFNSURLRequestFromRequestDataDoesNotOverrideDefaultValuesWithNull {
NSURLRequest *request =
FWFNSURLRequestFromRequestData([FWFNSUrlRequestData makeWithUrl:@"https://flutter.dev"
httpMethod:nil
httpBody:nil
allHttpHeaderFields:@{}]);

XCTAssertEqualObjects(request.HTTPMethod, @"GET");
}

- (void)testFWFNSHTTPCookieFromCookieData {
NSHTTPCookie *cookie = FWFNSHTTPCookieFromCookieData([FWFNSHttpCookieData
makeWithPropertyKeys:@[ [FWFNSHttpCookiePropertyKeyEnumData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
return nil;
}

[request setHTTPMethod:data.httpMethod];
[request setHTTPBody:data.httpBody.data];
if (data.httpMethod) {
[request setHTTPMethod:data.httpMethod];
}
if (data.httpBody) {
[request setHTTPBody:data.httpBody.data];
}
[request setAllHTTPHeaderFields:data.allHttpHeaderFields];

return request;
Expand Down

0 comments on commit a1af363

Please sign in to comment.