Skip to content

Releases: philharmonytech/http-message

v1.4.0

29 Mar 15:22
eec0440

Choose a tag to compare

v1.4.0

Added

  • Improved error handling in UploadedFile::getStream() with detailed error messages from error_get_last().
  • Support for UploadedFileFullPathInterface.

Changed

  • UploadedFile::__construct() now throws InvalidArgumentException instead of RuntimeException for invalid upload error status.
  • Suppressed warnings in Stream::openResource() using @ operator for safer resource handling.
  • Standardized README references (.yml.yaml) across all packages.

Fixed

  • Improved reliability of file handling when opening streams fails
  • Updated tests to reflect new exception behavior

v1.3.0

19 Mar 16:45
bc00bd8

Choose a tag to compare

This release introduces a new way to create streams directly from files and significantly improves the internal test suite.

Highlights

  • New Stream::createFromFile() method
    Create stream instances directly from file paths with proper error handling.
  • Improved test architecture
    The Stream test suite has been refactored to be more structured, maintainable, and consistent.
  • Better error handling coverage
    Added dedicated test scenarios for:
    • invalid stream states
    • system-level failures
    • PHP warning → exception conversion

Testing Improvements

  • Introduced reusable stub stream classes for precise control over edge cases:
    • BrokenStatsStream
    • FileOpenFailureStream
    • ForceReadableStream
    • ForceSeekableStream
    • ForceWritableStream
    • MemoryOpenFailureStream
  • Reduced duplication and improved clarity by using data providers in tests.

Internal Changes

  • Updated namespace for UploadErrorTest.
  • General cleanup and consistency improvements across tests.

v1.2.0

15 Mar 12:10
4989981

Choose a tag to compare

This release introduces multiple improvements across the PSR-7 HTTP message
implementation with a focus on stricter validation, better internal
consistency, and improved developer ergonomics.


Added

  • IPv6 host support in Uri.
  • Internationalized domain name (IDN) support using idn_to_ascii().
  • Added UploadError enum for representing PHP upload error codes.
  • Added ServerRequest::getRawBody() for accessing cached raw request bodies.
  • Added ServerRequest::input() and ServerRequest::has() helpers for retrieving values from query/body data.

Fixed

  • Message::setHeaders() now correctly replaces headers that differ only by case during initialization.
  • UploadedFile::moveTo() now ensures partially written files are cleaned up when stream copy fails.
  • Stream::__toString() now safely catches Throwable.
  • Response now validates that HTTP status codes are within the valid range (100–599).

Improved

  • Validation of URI host component.
  • Validation of percent-encoding in URI components.
  • Normalization of path when authority is present.
  • Detection of schemes that require a host.
  • Improved Stream mode detection using isReadableMode() and isWritableMode().
  • Improved Stream::close() readability.
  • Improved UploadedFile::moveTo() stream handling and error propagation.
  • Request now validates HTTP method tokens and exposes getMethodEnum().

Changed

  • with*() methods now return the same instance when the value does not change.
  • Query and fragment components now consistently normalize empty values.
  • Stream now uses is_array($stats) for safer stream size detection.
  • Internal stream reference is now reset using $this->stream = null instead of unset().
  • Stream::create() now rewinds the pointer when creating a stream from a non-empty string.
  • Refactored UploadedFile to internally use the UploadError enum.
  • ServerRequest now validates and normalizes nested uploaded file structures.

Performance

  • Request now caches the HttpMethod enum for helper methods such as isSafe() and isIdempotent().
  • Reduced body parsing overhead in ServerRequest.

Tests

  • Refactored and grouped Stream tests for better readability.
  • Added additional edge-case tests for stream behavior.
  • Added tests covering stream write failure cleanup.
  • Added tests for UploadError.
  • Added tests covering header replacement when header names differ only by case in Message::setHeaders().
  • Added tests verifying HTTP status code validation in Response.
  • Added tests covering Request::getMethodEnum() and withMethod() behavior.
  • Expanded ServerRequest coverage for input helpers, parsed body branches, raw body caching, and uploaded files normalization.

v1.0.1

05 Mar 16:18
16d5f87

Choose a tag to compare

v1.0.1 — Hotfix for PHP 8.1 compatibility

This is a maintenance release focused on stabilizing the CI pipeline and ensuring full compatibility with PHP 8.1 - 8.4 versions.

🛠 Fixed

  • Strict Header Validation — Fixed an issue where some control characters were not correctly identified on PHP 8.1.
  • Universal Regex — Replaced specific character matching with a robust inverted regex [^\x20-\x7E\t] to satisfy RFC 7230 across all supported PHP versions.
  • Type Safety — Resolved a TypeError in strlen() that occurred on PHP 8.4 when handling numeric header values.

⚙️ CI/CD Improvements

  • Optimized GitHub Actions workflows for better stability during Pull Requests.
  • Verified 100% code coverage on PHP 8.1, 8.2, 8.3, and 8.4.

v1.0.0

05 Mar 14:24
0a3da20

Choose a tag to compare

v1.0.0 — The Foundation: Strict & Smart PSR-7 Implementation

We are proud to announce the first stable release of philharmony/http-message. This package provides a high-performance, strictly typed implementation of PSR-7 (HTTP Message Interfaces), designed specifically for the modern PHP 8.4+ ecosystem.

✨ Key Features

  • Full PSR-7 Compliance — 100% interchangeable with any PSR-compliant middleware or library.
  • Strict Type Safety — Verified with PHPStan Level 9 to eliminate runtime type errors.
  • Native Enum Integration — Seamlessly works with philharmony/http-enum for status codes, methods, and content types.
  • Smart Helpers — Built-in methods like isJson(), isSafe(), isIdempotent(), and isSuccessful() for a superior developer experience.
  • Modern PHP Support — First-class support for PHP 8.1+ features, including the full_path key in uploaded files.
  • Security by Design — Robust URI parsing and header management following RFC 3986 and RFC 7230.

🛠 Technical Highlights

  • 100% Code Coverage — Every line and edge case is verified with PHPUnit 10.
  • Immutable by Design — All message objects are immutable, ensuring predictable state in middleware chains.
  • Polymorphic Streams — Flexible stream creation from strings, resources, or existing PSR-7 streams.

📦 Installation

composer require philharmony/http-message