Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan committed Aug 27, 2024
2 parents 3326df9 + 7f21111 commit d034402
Show file tree
Hide file tree
Showing 20 changed files with 745 additions and 68 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/health.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Health
on:
pull_request:
branches: [ master ]
types: [opened, synchronize, reopened, labeled, unlabeled]

jobs:
health:
uses: dart-lang/ecosystem/.github/workflows/health.yaml@main
with:
ignore_license: "**.g.dart"
sdk: dev
permissions:
pull-requests: write
17 changes: 17 additions & 0 deletions .github/workflows/post_summaries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Comment on the pull request

on:
# Trigger this workflow after the Health workflow completes. This workflow will have permissions to
# do things like create comments on the PR, even if the original workflow couldn't.
workflow_run:
workflows:
- Health
- Publish
types:
- completed

jobs:
upload:
uses: dart-lang/ecosystem/.github/workflows/post_summaries.yaml@main
permissions:
pull-requests: write
2 changes: 2 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
publish:
if: ${{ github.repository_owner == 'dart-lang' }}
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
with:
write-comments: false
permissions:
id-token: write # Required for authentication using OIDC
pull-requests: write # Required for writing the pull request note
4 changes: 4 additions & 0 deletions pkgs/http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.3-wip

* Fixed unintended HTML tags in doc comments.

## 1.2.2

* Require package `web: '>=0.5.0 <2.0.0'`.
Expand Down
30 changes: 15 additions & 15 deletions pkgs/http/lib/http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ Future<Response> get(Uri url, {Map<String, String>? headers}) =>

/// Sends an HTTP POST request with the given headers and body to the given URL.
///
/// [body] sets the body of the request. It can be a [String], a [List<int>] or
/// a [Map<String, String>]. If it's a String, it's encoded using [encoding] and
/// used as the body of the request. The content-type of the request will
/// [body] sets the body of the request. It can be a `String`, a `List<int>` or
/// a `Map<String, String>`. If it's a `String`, it's encoded using [encoding]
/// and used as the body of the request. The content-type of the request will
/// default to "text/plain".
///
/// If [body] is a List, it's used as a list of bytes for the body of the
/// If [body] is a `List`, it's used as a list of bytes for the body of the
/// request.
///
/// If [body] is a Map, it's encoded as form fields using [encoding]. The
/// If [body] is a `Map`, it's encoded as form fields using [encoding]. The
/// content-type of the request will be set to
/// `"application/x-www-form-urlencoded"`; this cannot be overridden.
///
Expand All @@ -73,15 +73,15 @@ Future<Response> post(Uri url,

/// Sends an HTTP PUT request with the given headers and body to the given URL.
///
/// [body] sets the body of the request. It can be a [String], a [List<int>] or
/// a [Map<String, String>]. If it's a String, it's encoded using [encoding] and
/// used as the body of the request. The content-type of the request will
/// [body] sets the body of the request. It can be a `String`, a `List<int>` or
/// a `Map<String, String>`. If it's a `String`, it's encoded using [encoding]
/// and used as the body of the request. The content-type of the request will
/// default to "text/plain".
///
/// If [body] is a List, it's used as a list of bytes for the body of the
/// If [body] is a `List`, it's used as a list of bytes for the body of the
/// request.
///
/// If [body] is a Map, it's encoded as form fields using [encoding]. The
/// If [body] is a `Map`, it's encoded as form fields using [encoding]. The
/// content-type of the request will be set to
/// `"application/x-www-form-urlencoded"`; this cannot be overridden.
///
Expand All @@ -97,15 +97,15 @@ Future<Response> put(Uri url,
/// Sends an HTTP PATCH request with the given headers and body to the given
/// URL.
///
/// [body] sets the body of the request. It can be a [String], a [List<int>] or
/// a [Map<String, String>]. If it's a String, it's encoded using [encoding] and
/// used as the body of the request. The content-type of the request will
/// [body] sets the body of the request. It can be a `String`, a `List<int>` or
/// a `Map<String, String>`. If it's a `String`, it's encoded using [encoding]
/// and used as the body of the request. The content-type of the request will
/// default to "text/plain".
///
/// If [body] is a List, it's used as a list of bytes for the body of the
/// If [body] is a `List`, it's used as a list of bytes for the body of the
/// request.
///
/// If [body] is a Map, it's encoded as form fields using [encoding]. The
/// If [body] is a `Map`, it's encoded as form fields using [encoding]. The
/// content-type of the request will be set to
/// `"application/x-www-form-urlencoded"`; this cannot be overridden.
///
Expand Down
11 changes: 6 additions & 5 deletions pkgs/http/lib/src/base_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ var _headerSplitter = RegExp(r'[ \t]*,[ \t]*');
///
/// Set-Cookie strings can contain commas. In particular, the following
/// productions defined in RFC-6265, section 4.1.1:
/// - <sane-cookie-date> e.g. "Expires=Sun, 06 Nov 1994 08:49:37 GMT"
/// - <path-value> e.g. "Path=somepath,"
/// - <extension-av> e.g. "AnyString,Really,"
/// - `<sane-cookie-date>` e.g. "Expires=Sun, 06 Nov 1994 08:49:37 GMT"
/// - `<path-value>` e.g. "Path=somepath,"
/// - `<extension-av>` e.g. "AnyString,Really,"
///
/// Some values are ambiguous e.g.
/// "Set-Cookie: lang=en; Path=/foo/"
Expand All @@ -128,8 +128,9 @@ var _headerSplitter = RegExp(r'[ \t]*,[ \t]*');
/// "Set-Cookie: lang=en; Path=/foo/,SID=x23"
/// would both be result in `response.headers` => "lang=en; Path=/foo/,SID=x23"
///
/// The idea behind this regex is that ",<valid token>=" is more likely to
/// start a new <cookie-pair> then be part of <path-value> or <extension-av>.
/// The idea behind this regex is that `,<valid token>=` is more likely to
/// start a new `<cookie-pair>` than be part of `<path-value>` or
/// `<extension-av>`.
///
/// See https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1
var _setCookieSplitter = RegExp(r'[ \t]*,[ \t]*(?=[' + _tokenChars + r']+=)');
Expand Down
28 changes: 14 additions & 14 deletions pkgs/http/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ abstract interface class Client {
/// Sends an HTTP POST request with the given headers and body to the given
/// URL.
///
/// [body] sets the body of the request. It can be a [String], a [List<int>]
/// or a [Map<String, String>].
/// [body] sets the body of the request. It can be a `String`, a `List<int>`
/// or a `Map<String, String>`.
///
/// If [body] is a String, it's encoded using [encoding] and used as the body
/// of the request. The content-type of the request will default to
/// If [body] is a `String`, it's encoded using [encoding] and used as the
/// body of the request. The content-type of the request will default to
/// "text/plain".
///
/// If [body] is a List, it's used as a list of bytes for the body of the
/// If [body] is a `List`, it's used as a list of bytes for the body of the
/// request.
///
/// If [body] is a Map, it's encoded as form fields using [encoding]. The
/// If [body] is a `Map`, it's encoded as form fields using [encoding]. The
/// content-type of the request will be set to
/// `"application/x-www-form-urlencoded"`; this cannot be overridden.
///
Expand All @@ -77,15 +77,15 @@ abstract interface class Client {
/// Sends an HTTP PUT request with the given headers and body to the given
/// URL.
///
/// [body] sets the body of the request. It can be a [String], a [List<int>]
/// or a [Map<String, String>]. If it's a String, it's encoded using
/// [body] sets the body of the request. It can be a `String`, a `List<int>`
/// or a `Map<String, String>`. If it's a `String`, it's encoded using
/// [encoding] and used as the body of the request. The content-type of the
/// request will default to "text/plain".
///
/// If [body] is a List, it's used as a list of bytes for the body of the
/// If [body] is a `List`, it's used as a list of bytes for the body of the
/// request.
///
/// If [body] is a Map, it's encoded as form fields using [encoding]. The
/// If [body] is a `Map`, it's encoded as form fields using [encoding]. The
/// content-type of the request will be set to
/// `"application/x-www-form-urlencoded"`; this cannot be overridden.
///
Expand All @@ -98,15 +98,15 @@ abstract interface class Client {
/// Sends an HTTP PATCH request with the given headers and body to the given
/// URL.
///
/// [body] sets the body of the request. It can be a [String], a [List<int>]
/// or a [Map<String, String>]. If it's a String, it's encoded using
/// [body] sets the body of the request. It can be a `String`, a `List<int>`
/// or a `Map<String, String>`. If it's a `String`, it's encoded using
/// [encoding] and used as the body of the request. The content-type of the
/// request will default to "text/plain".
///
/// If [body] is a List, it's used as a list of bytes for the body of the
/// If [body] is a `List`, it's used as a list of bytes for the body of the
/// request.
///
/// If [body] is a Map, it's encoded as form fields using [encoding]. The
/// If [body] is a `Map`, it's encoded as form fields using [encoding]. The
/// content-type of the request will be set to
/// `"application/x-www-form-urlencoded"`; this cannot be overridden.
///
Expand Down
2 changes: 1 addition & 1 deletion pkgs/http/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: http
version: 1.2.2
version: 1.2.3-wip
description: A composable, multi-platform, Future-based API for HTTP requests.
repository: https://github.com/dart-lang/http/tree/master/pkgs/http

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:stream_channel/stream_channel.dart';
/// On Startup:
/// - send port
/// On Request Received:
/// - send headers as Map<String, List<String>>
/// - send headers as `Map<String, List<String>>`
/// When Receive Anything:
/// - exit
void hybridMain(StreamChannel<Object?> channel) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'package:stream_channel/stream_channel.dart';
/// ".../9" | ".../8"
/// ... | ...
/// ".../1" | "/"
/// "/" | <200 return>
/// "/" | &lt;200 return&gt;
void hybridMain(StreamChannel<Object?> channel) async {
late HttpServer server;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:stream_channel/stream_channel.dart';
/// On Startup:
/// - send port
/// On Request Received:
/// - send headers as Map<String, List<String>>
/// - send headers as `Map<String, List<String>>`
/// When Receive Anything:
/// - exit
void hybridMain(StreamChannel<Object?> channel) async {
Expand Down
4 changes: 4 additions & 0 deletions pkgs/http_profile/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.1-wip

* Fixed unintended HTML tags in doc comments.

## 0.1.0

* Initial **experimental** release.
11 changes: 6 additions & 5 deletions pkgs/http_profile/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ var _headerSplitter = RegExp(r'[ \t]*,[ \t]*');
///
/// Set-Cookie strings can contain commas. In particular, the following
/// productions defined in RFC-6265, section 4.1.1:
/// - <sane-cookie-date> e.g. "Expires=Sun, 06 Nov 1994 08:49:37 GMT"
/// - <path-value> e.g. "Path=somepath,"
/// - <extension-av> e.g. "AnyString,Really,"
/// - `<sane-cookie-date>` e.g. "Expires=Sun, 06 Nov 1994 08:49:37 GMT"
/// - `<path-value>` e.g. "Path=somepath,"
/// - `<extension-av>` e.g. "AnyString,Really,"
///
/// Some values are ambiguous e.g.
/// "Set-Cookie: lang=en; Path=/foo/"
Expand All @@ -25,8 +25,9 @@ var _headerSplitter = RegExp(r'[ \t]*,[ \t]*');
/// "Set-Cookie: lang=en; Path=/foo/,SID=x23"
/// would both be result in `response.headers` => "lang=en; Path=/foo/,SID=x23"
///
/// The idea behind this regex is that ",<valid token>=" is more likely to
/// start a new <cookie-pair> then be part of <path-value> or <extension-av>.
/// The idea behind this regex is that `,<valid token>=` is more likely to
/// start a new `<cookie-pair>` than be part of `<path-value>` or
/// `<extension-av>`.
///
/// See https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1
var _setCookieSplitter = RegExp(r'[ \t]*,[ \t]*(?=[' + _tokenChars + r']+=)');
Expand Down
2 changes: 1 addition & 1 deletion pkgs/http_profile/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: >-
A library used by HTTP client authors to integrate with the DevTools Network
View.
repository: https://github.com/dart-lang/http/tree/master/pkgs/http_profile
version: 0.1.0
version: 0.1.1-wip

environment:
sdk: ^3.4.0
Expand Down
5 changes: 5 additions & 0 deletions pkgs/ok_http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.1-wip

- `OkHttpClient` now receives an `OkHttpClientConfiguration` to configure the client on a per-call basis.
- `OkHttpClient` supports setting four types of timeouts: [`connectTimeout`](https://square.github.io/okhttp/5.x/okhttp/okhttp3/-ok-http-client/-builder/connect-timeout.html), [`readTimeout`](https://square.github.io/okhttp/5.x/okhttp/okhttp3/-ok-http-client/-builder/read-timeout.html), [`writeTimeout`](https://square.github.io/okhttp/5.x/okhttp/okhttp3/-ok-http-client/-builder/write-timeout.html), and [`callTimeout`](https://square.github.io/okhttp/5.x/okhttp/okhttp3/-ok-http-client/-builder/call-timeout.html), using the `OkHttpClientConfiguration`.

## 0.1.0

- Implementation of [`BaseClient`](https://pub.dev/documentation/http/latest/http/BaseClient-class.html) and `send()` method using [`enqueue()` API](https://square.github.io/okhttp/5.x/okhttp/okhttp3/-call/enqueue.html)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Copyright (c) 2024, 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/http.dart';
import 'package:integration_test/integration_test.dart';
import 'package:ok_http/ok_http.dart';
import 'package:test/test.dart';

void testTimeouts() {
group('timeouts', () {
group('call timeout', () {
late HttpServer server;

setUp(() async {
server = (await HttpServer.bind('localhost', 0))
..listen((request) async {
// Add a delay of `n` seconds for URI `http://localhost:port/n`
final delay = int.parse(request.requestedUri.pathSegments.last);
await Future<void>.delayed(Duration(seconds: delay));

await request.drain<void>();
await request.response.close();
});
});
tearDown(() {
server.close();
});

test('exceeded', () {
final client = OkHttpClient(
configuration: const OkHttpClientConfiguration(
callTimeout: Duration(milliseconds: 500),
),
);
expect(
() async {
await client.get(Uri.parse('http://localhost:${server.port}/1'));
},
throwsA(
isA<ClientException>().having(
(exception) => exception.message,
'message',
startsWith('java.io.InterruptedIOException'),
),
),
);
});

test('not exceeded', () async {
final client = OkHttpClient(
configuration: const OkHttpClientConfiguration(
callTimeout: Duration(milliseconds: 1500),
),
);
final response = await client.send(
Request(
'GET',
Uri.http('localhost:${server.port}', '1'),
),
);

expect(response.statusCode, 200);
expect(response.contentLength, 0);
});

test('not set', () async {
final client = OkHttpClient();

expect(
() async {
await client.send(
Request(
'GET',
Uri.http('localhost:${server.port}', '11'),
),
);
},
throwsA(
isA<ClientException>().having(
(exception) => exception.message,
'message',
startsWith('java.net.SocketTimeoutException'),
),
),
);
});
});
});
}

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testTimeouts();
}
1 change: 1 addition & 0 deletions pkgs/ok_http/jnigen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ classes:
- "com.example.ok_http.WebSocketListenerProxy"
- "okio.ByteString"
- "com.example.ok_http.WebSocketInterceptor"
- "java.util.concurrent.TimeUnit"

# Exclude the deprecated methods listed below
# They cause syntax errors during the `dart format` step of JNIGen.
Expand Down
Loading

0 comments on commit d034402

Please sign in to comment.