-
Notifications
You must be signed in to change notification settings - Fork 362
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
Add a skeleton "http_profile" package #1036
Merged
brianquinlan
merged 6 commits into
dart-lang:master
from
brianquinlan:http_profile_create
Nov 2, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6c4ed25
Add a skeleton "http_profile" package
brianquinlan 5a96147
Add copyright
brianquinlan 8bd133c
Update pkgs/http_profile/pubspec.yaml
brianquinlan 5bc5801
Review fixes #1
brianquinlan d9520a6
Merge branch 'http_profile_create' of github.com:brianquinlan/http in…
brianquinlan bbae449
Update pkgs/http_profile/lib/http_profile.dart
brianquinlan 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,3 @@ | ||
## 0.0.1 | ||
|
||
* Skeleton class and test definitions. |
This file contains 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,27 @@ | ||
Copyright 2023, the Dart project authors. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google LLC nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains 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,2 @@ | ||
An **experimental** package that allows HTTP clients outside of the Dart SDK | ||
to integrate with the DevTools Network tab. |
This file contains 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,33 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
import 'dart:io'; | ||
|
||
/// A record of debugging information about an HTTP request. | ||
final class HttpClientRequestProfile { | ||
/// Whether HTTP profiling is enabled or not. | ||
/// | ||
/// The value can be changed programmatically or through the DevTools Network | ||
/// UX. | ||
static bool get profilingEnabled => HttpClient.enableTimelineLogging; | ||
static set profilingEnabled(bool enabled) => | ||
HttpClient.enableTimelineLogging = enabled; | ||
|
||
String? requestMethod; | ||
String? requestUri; | ||
|
||
HttpClientRequestProfile._(); | ||
|
||
/// If HTTP profiling is enabled, returns | ||
/// a [HttpClientRequestProfile] otherwise returns `null`. | ||
static HttpClientRequestProfile? profile() { | ||
// Always return `null` in product mode so that the | ||
// profiling code can be tree shaken away. | ||
if (const bool.fromEnvironment('dart.vm.product') || !profilingEnabled) { | ||
return null; | ||
} | ||
final requestProfile = HttpClientRequestProfile._(); | ||
return requestProfile; | ||
} | ||
} |
This file contains 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,14 @@ | ||
sdk: | ||
- pubspec | ||
- dev | ||
|
||
stages: | ||
- analyze_and_format: | ||
- analyze: --fatal-infos | ||
- format: | ||
sdk: | ||
- dev | ||
- unit_test: | ||
- test: --platform vm | ||
os: | ||
- linux |
This file contains 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,15 @@ | ||
name: http_profile | ||
description: >- | ||
A library used by HTTP client authors to integrate with the DevTools | ||
Network tab. | ||
publish_to: none | ||
repository: https://github.com/dart-lang/http/tree/master/pkgs/http_profile | ||
|
||
environment: | ||
sdk: ^3.0.0 | ||
|
||
dependencies: | ||
test: ^1.24.9 | ||
|
||
dev_dependencies: | ||
dart_flutter_team_lints: ^2.1.1 |
This file contains 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,22 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:http_profile/http_profile.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('profiling enabled', () async { | ||
HttpClientRequestProfile.profilingEnabled = true; | ||
expect(HttpClient.enableTimelineLogging, true); | ||
expect(HttpClientRequestProfile.profile(), isNotNull); | ||
}); | ||
|
||
test('profiling disabled', () async { | ||
HttpClientRequestProfile.profilingEnabled = false; | ||
expect(HttpClient.enableTimelineLogging, false); | ||
expect(HttpClientRequestProfile.profile(), isNull); | ||
}); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you expand the commit message (I usually edit the first PR comment then copy it to the message when I squash/merge) to include more details about how this class will be used by the SDK/DevTools?
What code will fill these fields in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the commit message.