Releases: philharmonytech/http-message
Releases · philharmonytech/http-message
v1.4.0
v1.4.0
Added
- Improved error handling in
UploadedFile::getStream()with detailed error messages fromerror_get_last(). - Support for
UploadedFileFullPathInterface.
Changed
UploadedFile::__construct()now throwsInvalidArgumentExceptioninstead ofRuntimeExceptionfor 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
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:
BrokenStatsStreamFileOpenFailureStreamForceReadableStreamForceSeekableStreamForceWritableStreamMemoryOpenFailureStream
- 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
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
UploadErrorenum for representing PHP upload error codes. - Added
ServerRequest::getRawBody()for accessing cached raw request bodies. - Added
ServerRequest::input()andServerRequest::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 catchesThrowable.Responsenow 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
Streammode detection usingisReadableMode()andisWritableMode(). - Improved
Stream::close()readability. - Improved
UploadedFile::moveTo()stream handling and error propagation. Requestnow validates HTTP method tokens and exposesgetMethodEnum().
Changed
with*()methods now return the same instance when the value does not change.- Query and fragment components now consistently normalize empty values.
Streamnow usesis_array($stats)for safer stream size detection.- Internal stream reference is now reset using
$this->stream = nullinstead ofunset(). Stream::create()now rewinds the pointer when creating a stream from a non-empty string.- Refactored
UploadedFileto internally use theUploadErrorenum. ServerRequestnow validates and normalizes nested uploaded file structures.
Performance
Requestnow caches theHttpMethodenum for helper methods such asisSafe()andisIdempotent().- Reduced body parsing overhead in
ServerRequest.
Tests
- Refactored and grouped
Streamtests 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()andwithMethod()behavior. - Expanded
ServerRequestcoverage for input helpers, parsed body branches, raw body caching, and uploaded files normalization.
v1.0.1
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
TypeErrorinstrlen()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
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-enumfor status codes, methods, and content types. - Smart Helpers — Built-in methods like
isJson(),isSafe(),isIdempotent(), andisSuccessful()for a superior developer experience. - Modern PHP Support — First-class support for PHP 8.1+ features, including the
full_pathkey 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