Skip to content

Added cache control for http request within BrowserClient #1706

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

Open
wants to merge 40 commits into
base: master
Choose a base branch
from

Conversation

seifibrahim32
Copy link

@seifibrahim32 seifibrahim32 commented Feb 2, 2025

Added cache control for BrowserClient and passed 85 conformance tests including fixes in tests for html runtime.

@seifibrahim32 seifibrahim32 changed the title Added cache control for http request for BrowserClient Added cache control for http request within BrowserClient Feb 2, 2025
Copy link
Collaborator

@brianquinlan brianquinlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for this. There are cache testing examples here:

@seifibrahim32

This comment was marked as duplicate.

Copy link
Collaborator

@brianquinlan brianquinlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to write tests! ;-)

Copy link

github-actions bot commented Feb 5, 2025

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

Coverage ⚠️
File Coverage
pkgs/http/lib/browser_client.dart 💔 Not covered
pkgs/http/lib/src/browser_client.dart 💔 Not covered

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/http/example/main.dart
pkgs/http_client_conformance_tests/example/client_test.dart
pkgs/http_client_conformance_tests/lib/src/dummy_isolate.dart
pkgs/http_parser/test/example_test.dart
pkgs/http_profile/lib/http_profile.dart
pkgs/web_socket/example/web_socket_example.dart
pkgs/web_socket/lib/testing.dart
pkgs/web_socket_conformance_tests/example/client_test.dart

@seifibrahim32
Copy link
Author

seifibrahim32 commented Feb 5, 2025

@brianquinlan I will add tests but, I want to make sure that everything goes good within the design.
@kevmoo I am thinking of changing from String to CacheOption and we get the String type within the enum.

@seifibrahim32 seifibrahim32 requested a review from kevmoo February 5, 2025 22:12
@github-actions github-actions bot added the type-infra A repository infrastructure change or enhancement label Mar 10, 2025
@seifibrahim32
Copy link
Author

@brianquinlan Hello, I am back once again.
The tests are ready..
Waiting to hear back from you.

Copy link

Package publishing

Package Version Status Publish tag (post-merge)
package:cronet_http 1.3.3-wip WIP (no publish necessary)
package:cupertino_http 2.0.3-wip WIP (no publish necessary)
package:http 1.5.0 ready to publish http-v1.5.0
package:http2 2.3.2-wip WIP (no publish necessary)
package:http_multi_server 3.2.2 already published at pub.dev
package:http_parser 4.1.2 already published at pub.dev
package:http_profile 0.1.1-wip WIP (no publish necessary)
package:ok_http 0.1.1-wip WIP (no publish necessary)
package:web_socket 0.1.6 already published at pub.dev
package:web_socket_channel 3.0.2 already published at pub.dev

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

@github-actions github-actions bot removed the type-infra A repository infrastructure change or enhancement label Mar 12, 2025
});

test('#send a GET with default type', () async {
var client = BrowserClient(cacheMode: CacheMode.defaultType);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are only doing a single request here so I'm not sure how this is testing the caching behavior.

Copy link
Author

@seifibrahim32 seifibrahim32 Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it is two GET requests, when it is set to default type it is cached once.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, I need to drain the request so, I can see the difference.

client.close();
expect(
response.body,
parse(anyOf(containsPair('numOfRequests', 2),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't numOfRequests always be 2?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see most of other tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have other suggestions regarding the tests? @brianquinlan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants