From 2e2da7dd30f743349f691b5861395b5c240c09fa Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Mon, 13 Jun 2022 12:48:19 -0700 Subject: [PATCH 1/2] null method fix --- .../example/ios/RunnerTests/FWFDataConvertersTests.m | 10 ++++++++++ .../ios/Classes/FWFDataConverters.m | 12 +++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFDataConvertersTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFDataConvertersTests.m index 1fc5a95398bd..ca7d6f938599 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFDataConvertersTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFDataConvertersTests.m @@ -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 diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m index 759bfedc1621..116d950e4aea 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m @@ -17,9 +17,15 @@ return nil; } - [request setHTTPMethod:data.httpMethod]; - [request setHTTPBody:data.httpBody.data]; - [request setAllHTTPHeaderFields:data.allHttpHeaderFields]; + if (data.httpMethod) { + [request setHTTPMethod:data.httpMethod]; + } + if (data.httpBody) { + [request setHTTPBody:data.httpBody.data]; + } + if (data.allHttpHeaderFields) { + [request setAllHTTPHeaderFields:data.allHttpHeaderFields]; + } return request; } From 51bdb48284e7d7949e4c3d2637f962202de43e1d Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:51:46 -0700 Subject: [PATCH 2/2] unneeded null check --- .../webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m index 116d950e4aea..8ecc9d303000 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m @@ -23,9 +23,7 @@ if (data.httpBody) { [request setHTTPBody:data.httpBody.data]; } - if (data.allHttpHeaderFields) { - [request setAllHTTPHeaderFields:data.allHttpHeaderFields]; - } + [request setAllHTTPHeaderFields:data.allHttpHeaderFields]; return request; }