-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[webview_platform_interface] Adds WebResourceRequest to HttpResponseError #5790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
auto-submit
merged 16 commits into
flutter:main
from
bparrishMines:web_resource_request_2
Jan 22, 2024
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
12588bf
Adds the web resource request to HttpResponseError
HugoOlthof 5016358
Adds empty line
HugoOlthof c7600f0
Bumps version and updates the changelog
HugoOlthof bc00802
Adds WebResourceResponse class
HugoOlthof 71f3d19
Updates changelog
HugoOlthof 9c519f5
Implemented feedback
HugoOlthof 1cdaa00
Fixes formatting
HugoOlthof 66986c2
Moves statusCode to HttpResponseError
HugoOlthof 7e861b7
Changed request type in WebResourceResponse to String
HugoOlthof 6df7c99
add exports and uri
bparrishMines 88af241
Merge branch 'main' of github.com:flutter/packages into web-resource-…
bparrishMines 2daf57b
add test
bparrishMines 30475ac
Merge branch 'main' of github.com:flutter/packages into web_resource_…
bparrishMines 87be1a4
Merge branch 'main' of github.com:flutter/packages into web_resource_…
bparrishMines 281f8fa
rename test file
bparrishMines 1ddc2f5
update tests
bparrishMines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/webview_flutter/webview_flutter_platform_interface/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ebview_flutter/webview_flutter_platform_interface/lib/src/types/web_resource_request.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/foundation.dart'; | ||
|
||
/// Defines the parameters of the web resource request from the associated request. | ||
/// | ||
/// Platform specific implementations can add additional fields by extending | ||
/// this class. | ||
/// | ||
/// This example demonstrates how to extend the [WebResourceRequest] to | ||
/// provide additional platform specific parameters. | ||
/// | ||
/// When extending [WebResourceRequest] additional parameters should always | ||
/// accept `null` or have a default value to prevent breaking changes. | ||
/// | ||
/// ```dart | ||
/// class AndroidWebResourceRequest extends WebResourceRequest { | ||
/// WebResourceRequest._({ | ||
/// required WebResourceRequest request, | ||
/// }) : super( | ||
/// uri: request.uri, | ||
/// ); | ||
/// | ||
/// factory AndroidWebResourceRequest.fromWebResourceRequest( | ||
/// WebResourceRequest request, { | ||
/// Map<String, String> headers, | ||
/// }) { | ||
/// return AndroidWebResourceRequest._(request, headers: headers); | ||
/// } | ||
/// | ||
/// final Map<String, String> headers; | ||
/// } | ||
/// ``` | ||
@immutable | ||
class WebResourceRequest { | ||
/// Used by the platform implementation to create a new [WebResourceRequest]. | ||
const WebResourceRequest({required this.uri}); | ||
|
||
/// URI for the request. | ||
final Uri uri; | ||
} |
55 changes: 55 additions & 0 deletions
55
...bview_flutter/webview_flutter_platform_interface/lib/src/types/web_resource_response.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/foundation.dart'; | ||
|
||
/// Contains information about the response for a request. | ||
/// | ||
/// Platform specific implementations can add additional fields by extending | ||
/// this class. | ||
/// | ||
/// This example demonstrates how to extend the [WebResourceResponse] to | ||
/// provide additional platform specific parameters. | ||
/// | ||
/// When extending [WebResourceResponse] additional parameters should always | ||
/// accept `null` or have a default value to prevent breaking changes. | ||
/// | ||
/// ```dart | ||
/// class AndroidWebResourceResponse extends WebResourceResponse { | ||
/// WebResourceResponse._({ | ||
/// required WebResourceResponse response, | ||
/// }) : super( | ||
/// uri: response.uri, | ||
/// statusCode: response.statusCode, | ||
/// headers: response.headers, | ||
/// ); | ||
/// | ||
/// factory AndroidWebResourceResponse.fromWebResourceResponse( | ||
/// WebResourceResponse response, { | ||
/// Uri? historyUrl, | ||
/// }) { | ||
/// return AndroidWebResourceResponse._(response, historyUrl: historyUrl); | ||
/// } | ||
/// | ||
/// final Uri? historyUrl; | ||
/// } | ||
/// ``` | ||
@immutable | ||
class WebResourceResponse { | ||
/// Used by the platform implementation to create a new [WebResourceResponse]. | ||
const WebResourceResponse({ | ||
required this.uri, | ||
required this.statusCode, | ||
this.headers = const <String, String>{}, | ||
}); | ||
|
||
/// The URI that this response is associated with. | ||
final Uri? uri; | ||
|
||
/// The HTTP status code. | ||
final int statusCode; | ||
|
||
/// Headers for the request. | ||
final Map<String, String> headers; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/webview_flutter/webview_flutter_platform_interface/test/types_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:webview_flutter_platform_interface/src/types/types.dart'; | ||
|
||
void main() { | ||
group('types', () { | ||
test('WebResourceRequest', () { | ||
final Uri uri = Uri.parse('https://www.google.com'); | ||
final WebResourceRequest request = WebResourceRequest(uri: uri); | ||
expect(request.uri, uri); | ||
}); | ||
|
||
test('WebResourceResponse', () { | ||
final Uri uri = Uri.parse('https://www.google.com'); | ||
const int statusCode = 404; | ||
const Map<String, String> headers = <String, String>{'a': 'header'}; | ||
|
||
final WebResourceResponse response = WebResourceResponse( | ||
uri: uri, | ||
statusCode: statusCode, | ||
headers: headers, | ||
); | ||
|
||
expect(response.uri, uri); | ||
expect(response.statusCode, statusCode); | ||
expect(response.headers, headers); | ||
}); | ||
}); | ||
} |
40 changes: 40 additions & 0 deletions
40
...bview_flutter_platform_interface/test/webview_flutter_platform_interface_export_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// ignore_for_file: unnecessary_statements | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart' | ||
as main_file; | ||
|
||
void main() { | ||
test( | ||
'ensures webview_flutter_platform_interface.dart exports classes in types directory', | ||
() { | ||
main_file.JavaScriptConsoleMessage; | ||
main_file.JavaScriptLogLevel; | ||
main_file.JavaScriptMessage; | ||
main_file.JavaScriptMode; | ||
main_file.LoadRequestMethod; | ||
main_file.NavigationDecision; | ||
main_file.NavigationRequest; | ||
main_file.NavigationRequestCallback; | ||
main_file.PageEventCallback; | ||
main_file.PlatformNavigationDelegateCreationParams; | ||
main_file.PlatformWebViewControllerCreationParams; | ||
main_file.PlatformWebViewCookieManagerCreationParams; | ||
main_file.PlatformWebViewPermissionRequest; | ||
main_file.PlatformWebViewWidgetCreationParams; | ||
main_file.ProgressCallback; | ||
main_file.WebViewPermissionResourceType; | ||
main_file.WebResourceRequest; | ||
main_file.WebResourceResponse; | ||
main_file.WebResourceError; | ||
main_file.WebResourceErrorCallback; | ||
main_file.WebViewCookie; | ||
main_file.WebResourceErrorType; | ||
main_file.UrlChange; | ||
}, | ||
); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.