Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Everyone who takes part follows the
## Setup

You need Composer, PHP 8.4 or a later 8.x with the `sockets`, `pdo_sqlite` and `curl` extensions,
and pcov or Xdebug for line coverage. The two browser examples also need Chrome; see the `Example`
suite below.
and pcov or Xdebug for line coverage. The two browser tests also need Chrome; see [Tests](#tests).

```sh
composer install
Expand Down Expand Up @@ -39,8 +38,9 @@ composer test # Pint and Rector dry runs, PHPStan, 100% type cove
Before you open a pull request:

```sh
composer test:coverage # 100% line coverage, needs pcov or Xdebug
composer lint # Rector, then Pint
composer test # the dry runs of both, PHPStan, 100% type coverage, every suite
composer test:coverage # 100% line coverage, needs pcov or Xdebug
composer validate --strict # composer.json against its schema
composer audit --locked # advisories for the locked packages, needs the network
```
Expand All @@ -50,7 +50,7 @@ PHPStan, Rector and the type coverage read `src` and `tests`; Pint reads the who
The code must run on PHP 8.4 and 8.5, on macOS, and on Linux with glibc and with musl. The Docker
jobs in CI run the suites as a non-root user, so that the file-mode tests run. To run
such a job locally, use a clean clone, because the command copies the whole directory. Use `debian`
or `alpine` as the image name:
or `alpine` as the directory in `.github/docker/`:

```sh
docker build --quiet --tag tests .github/docker/debian
Expand Down Expand Up @@ -81,9 +81,10 @@ docker run --rm --volume "$PWD:/src:ro" --workdir /src actionlint -no-color

- Where Go `net/http` decides the result, the test is a probe in
`tests/Fixtures/go-net-http/cases.json`, with the fields `group`, `name`, `source: "probe"`,
`rule` (Go's file and function) and `request`, and the limits `maxHeaderBytes` or
`maxHeaderValueCount` where needed. Then run `composer go:extract`. The `GoNetHttp` suite sends
the probe to Go for the parser and to FrankenPHP for the response, and compares the bytes.
`rule` (Go's file and function) and `request`, and the limits `maxHeaderBytes`,
`maxHeaderValueCount` or `maxBody` where needed. Then run `composer go:extract`. The `GoNetHttp`
suite sends the probe to Go for the parser and to FrankenPHP for the response, and compares the
bytes.
- Where Caddy decides, the probe goes into `tests/Fixtures/caddy/cases.json` in the same form, with
Caddy's file and function as `rule`, and the `FrankenPhp` suite compares it against FrankenPHP.
- No test spells out a FrankenPHP response as a literal. Where the handler must be PHP, compare
Expand Down Expand Up @@ -139,12 +140,12 @@ composer frankenphp:lock # new FrankenPHP versions into release.lock, needs gh
- The newest FrankenPHP is its newest release, not its newest tag: upstream tags a version and
publishes the release hours later.
- `check:frankenphp` downloads the newest FrankenPHP binary into `.frankenphp/newest` and runs it.
When it finds new versions, run `composer frankenphp:lock`. It writes the versions of the newest
When it finds new versions, run `composer frankenphp:lock`. `frankenphp:lock` writes the versions of the newest
binary into `release.lock` after `gh attestation verify` shows that FrankenPHP's workflow built
each binary. If the versions are unchanged, it writes nothing.
- Then update each lock file that the `pins` group test in `tests/FrankenPhp/FrankenPhpTest.php`
reads, each version that it names, and the tags in `tests/Fixtures/README.md`. The README names
no pinned version.
reads, each version that it names, and the tags in `tests/Fixtures/README.md`. The root README
names no pinned version.

## Scope

Expand Down
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- See .github/CONTRIBUTING.md. A vulnerability goes to the security policy, not here. -->
<!-- See .github/CONTRIBUTING.md. Report a vulnerability as the security policy describes, not here. -->

**What goes wrong, or what the feature does:**
**What went wrong and what you expected, or what the feature does; with a fix, why it works:**

**The row of Scope in the README that it touches, and the layer that decides it:**

Expand Down
33 changes: 20 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,32 @@ All notable changes to this package are in this file. The format follows

## [Unreleased]

### Changed
## [1.1.0] - 2026-11-21

- Four more messages name the way out: `ClosedWithErrors` names a request cut by `close()` and the
`onError` that fails the test at the error; a chunk that is not a string names `json_encode()`; a handler that returns `null`
is told to return a `Response` from every path; a host that is not loopback names where the
browser runs.
### Changed

- For a name such as `localhost`, the server listens on the address that its loopback check
resolved the name to. When the port is taken there, `new Server()` throws `ListenFailed` instead
of trying the next address.
- For a `$host` with a port or a scheme, such as `127.0.0.1:8080`, `new Server()` throws
`ListenFailed` at once and names `$port`, instead of passing on an error of the resolver. For a
host that cannot be bound, the message of `ListenFailed` contains "could not bind".
- Error messages name the way out:
- a handler that returns `null`: return a `Response` from every path;
- a handler that returns another value: the fully qualified `Response` class and the README
section "Works with Symfony, Laravel and PSR-15";
- `ClosedWithErrors`: fix the handler or let each request finish before `close()`, and the
`onError` that fails the test at the error;
- a chunk of a streamed body that is not a string: `json_encode()` for JSON;
- a host that is not loopback: run the browser on the same host or in the same container.
- `SECURITY.md` moved to `.github/` and is no longer in the package. The security link in
`composer.json` points to the security policy on GitHub.
- Three messages name the fix. A handler that gives another type than `Response` names the full
class and the section "Works with Symfony, Laravel and PSR-15". `ClosedWithErrors` says to fix
the handler first. A `$host` with a port or a scheme, such as `127.0.0.1:8080`, throws
`ListenFailed` at once and names `$port`, instead of an error of the resolver.

### Fixed

- `new Server()` refuses a host that resolves to an address that is not loopback, such as
`0.0.0.0` or `0`, before it listens. Until now it listened on the address for a moment and then
refused it. A host that cannot be bound now throws `ListenFailed` with "could not bind". A name
such as `localhost` now listens only on the first address it resolves to.
`0.0.0.0` or `0`, before it listens. Previously, it listened on the address for a moment and
then refused it.

## [1.0.0] - 2026-11-20

Expand All @@ -38,5 +44,6 @@ response with the FrankenPHP binary, in the form that Chrome receives, and the p
`net/http`. The README states the scope and each deliberate difference. The 0.x releases were
private.

[Unreleased]: https://github.com/sorge-it/http-server/compare/v1.0.0...HEAD
[Unreleased]: https://github.com/sorge-it/http-server/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/sorge-it/http-server/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/sorge-it/http-server/releases/tag/v1.0.0
Loading
Loading