Skip to content

Commit

Permalink
Merge package:http_parser into the http monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Oct 17, 2024
2 parents 75bd389 + 85d2651 commit 86e6070
Show file tree
Hide file tree
Showing 28 changed files with 2,608 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkgs/http_parser/.github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Dependabot configuration file.
version: 2

updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
labels:
- autosubmit
groups:
github-actions:
patterns:
- "*"
37 changes: 37 additions & 0 deletions pkgs/http_parser/.github/workflows/no-response.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# A workflow to close issues where the author hasn't responded to a request for
# more information; see https://github.com/actions/stale.

name: No Response

# Run as a daily cron.
on:
schedule:
# Every day at 8am
- cron: '0 8 * * *'

# All permissions not specified are set to 'none'.
permissions:
issues: write
pull-requests: write

jobs:
no-response:
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'dart-lang' }}
steps:
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e
with:
# Don't automatically mark inactive issues+PRs as stale.
days-before-stale: -1
# Close needs-info issues and PRs after 14 days of inactivity.
days-before-close: 14
stale-issue-label: "needs-info"
close-issue-message: >
Without additional information we're not able to resolve this issue.
Feel free to add more info or respond to any questions above and we
can reopen the case. Thanks for your contribution!
stale-pr-label: "needs-info"
close-pr-message: >
Without additional information we're not able to resolve this PR.
Feel free to add more info or respond to any questions above.
Thanks for your contribution!
17 changes: 17 additions & 0 deletions pkgs/http_parser/.github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# A CI configuration to auto-publish pub packages.

name: Publish

on:
pull_request:
branches: [ master ]
push:
tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ]

jobs:
publish:
if: ${{ github.repository_owner == 'dart-lang' }}
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
permissions:
id-token: write # Required for authentication using OIDC
pull-requests: write # Required for writing the pull request note
64 changes: 64 additions & 0 deletions pkgs/http_parser/.github/workflows/test-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Dart CI

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github
permissions: read-all

jobs:
# Check code formatting and static analysis on a single OS (linux)
# against Dart dev.
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [dev]
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'

test:
needs: analyze
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
sdk: [3.4, dev]
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Run VM tests
run: dart test --platform vm
if: always() && steps.install.outcome == 'success'
- name: Run Chrome tests
run: dart test --platform chrome
if: always() && steps.install.outcome == 'success'
- name: Run Chrome tests - wasm
run: dart test --platform chrome --compiler dart2wasm
if: always() && steps.install.outcome == 'success'
4 changes: 4 additions & 0 deletions pkgs/http_parser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Don’t commit the following directories created by pub.
.dart_tool/
.packages
pubspec.lock
142 changes: 142 additions & 0 deletions pkgs/http_parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
## 4.1.0

* `CaseInsensitiveMap`: added constructor `fromEntries`.
* Require `package:collection` `^1.19.0`
* Require Dart `^3.4.0`

## 4.0.2

* Remove `package:charcode` from dev_dependencies.

## 4.0.1

* Remove dependency on `package:charcode`.

## 4.0.0

* Stable null safety stable release.

## 4.0.0-nullsafety

* Migrate to null safety.

## 3.1.4

* Fixed lints affecting package health score.
* Added an example.

## 3.1.3

* Set max SDK version to `<3.0.0`, and adjust other dependencies.

## 3.1.2

* Require Dart SDK 2.0.0-dev.17.0 or greater.

* A number of strong-mode fixes.

## 3.1.1

* Fix a logic bug in the `chunkedCoding` codec. It had been producing invalid
output and rejecting valid input.

## 3.1.0

* Add `chunkedCoding`, a `Codec` that supports encoding and decoding the
[chunked transfer coding][].

[chunked transfer coding]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1

## 3.0.2

* Support `string_scanner` 1.0.0.

## 3.0.1

* Remove unnecessary dependencies.

## 3.0.0

* All deprecated APIs have been removed. No new APIs have been added. Packages
that would use 3.0.0 as a lower bound should use 2.2.0 instead—for example,
`http_parser: ">=2.2.0 <4.0.0"`.

* Fix all strong-mode warnings.

## 2.2.1

* Add support for `crypto` 1.0.0.

## 2.2.0

* `WebSocketChannel` has been moved to
[the `web_socket_channel` package][web_socket_channel]. The implementation
here is now deprecated.

[web_socket_channel]: https://pub.dev/packages/web_socket_channel

## 2.1.0

* Added `WebSocketChannel`, an implementation of `StreamChannel` that's backed
by a `WebSocket`.

* Deprecated `CompatibleWebSocket` in favor of `WebSocketChannel`.

## 2.0.0

* Removed the `DataUri` class. It's redundant with the `Uri.data` getter that's
coming in Dart 1.14, and the `DataUri.data` field in particular was an invalid
override of that field.

## 1.1.0

* The MIME spec says that media types and their parameter names are
case-insensitive. Accordingly, `MediaType` now uses a case-insensitive map for
its parameters and its `type` and `subtype` fields are now always lowercase.

## 1.0.0

This is 1.0.0 because the API is stable—there are no breaking changes.

* Added an `AuthenticationChallenge` class for parsing and representing the
value of `WWW-Authenticate` and related headers.

* Added a `CaseInsensitiveMap` class for representing case-insensitive HTTP
values.

## 0.0.2+8

* Bring in the latest `dart:io` WebSocket code.

## 0.0.2+7

* Add more detail to the readme.

## 0.0.2+6

* Updated homepage URL.

## 0.0.2+5

* Widen the version constraint on the `collection` package.

## 0.0.2+4

* Widen the `string_scanner` version constraint.

## 0.0.2+3

* Fix a library name conflict.

## 0.0.2+2

* Fixes for HTTP date formatting.

## 0.0.2+1

* Minor code refactoring.

## 0.0.2

* Added `CompatibleWebSocket`, for platform- and API-independent support for the
WebSocket API.
27 changes: 27 additions & 0 deletions pkgs/http_parser/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2014, 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.
23 changes: 23 additions & 0 deletions pkgs/http_parser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[![Build Status](https://github.com/dart-lang/http_parser/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/http_parser/actions?query=workflow%3A"Dart+CI"+branch%3Amaster)
[![Pub Package](https://img.shields.io/pub/v/http_parser.svg)](https://pub.dartlang.org/packages/http_parser)
[![package publisher](https://img.shields.io/pub/publisher/http_parser.svg)](https://pub.dev/packages/http_parser/publisher)

`http_parser` is a platform-independent package for parsing and serializing
various HTTP-related formats. It's designed to be usable on both the browser and
the server, and thus avoids referencing any types from `dart:io` or `dart:html`.

## Features

* Support for parsing and formatting dates according to [HTTP/1.1][2616], the
HTTP/1.1 standard.

* A `MediaType` class that represents an HTTP media type, as used in `Accept`
and `Content-Type` headers. This class supports both parsing and formatting
media types according to [HTTP/1.1][2616].

* A `WebSocketChannel` class that provides a `StreamChannel` interface for both
the client and server sides of the [WebSocket protocol][6455] independently of
any specific server implementation.

[2616]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html
[6455]: https://tools.ietf.org/html/rfc6455
33 changes: 33 additions & 0 deletions pkgs/http_parser/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# https://dart.dev/tools/analysis#the-analysis-options-file
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true

linter:
rules:
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_returning_this
- avoid_unused_constructor_parameters
- avoid_void_async
- cancel_subscriptions
- join_return_with_assignment
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_runtimeType_toString
- package_api_docs
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_locals
- unnecessary_await_in_return
- unnecessary_breaks
- use_if_null_to_convert_nulls_to_bools
- use_raw_strings
- use_string_buffers
16 changes: 16 additions & 0 deletions pkgs/http_parser/example/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2020, 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 'package:http_parser/http_parser.dart';

void main() {
final date = DateTime.utc(2014, 9, 9, 9, 9, 9);
print(date); // 2014-09-09 09:09:09.000Z

final httpDateFormatted = formatHttpDate(date);
print(httpDateFormatted); // Tue, 09 Sep 2014 09:09:09 GMT

final nowParsed = parseHttpDate(httpDateFormatted);
print(nowParsed); // 2014-09-09 09:09:09.000Z
}
9 changes: 9 additions & 0 deletions pkgs/http_parser/lib/http_parser.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) 2014, 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.

export 'src/authentication_challenge.dart';
export 'src/case_insensitive_map.dart';
export 'src/chunked_coding.dart';
export 'src/http_date.dart';
export 'src/media_type.dart';
Loading

0 comments on commit 86e6070

Please sign in to comment.