-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a skeleton "http_profile" package (#1036)
- Loading branch information
1 parent
b9389fe
commit 04777ac
Showing
9 changed files
with
179 additions
and
18 deletions.
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.