Repository navigation
Wrap a response body that breaks off mid-read in an IncompleteResponseException - #30
Merged
Merged
Conversation
…body; changelog Added and BC notes
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.x #30 +/- ##
============================================
+ Coverage 99.14% 99.17% +0.03%
- Complexity 226 230 +4
============================================
Files 27 28 +1
Lines 582 605 +23
============================================
+ Hits 577 600 +23
Misses 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #29.
One deliberate deviation from the agent brief:
IncompleteResponseExceptionimplements onlyQuickpayException, not PSR-18NetworkExceptionInterface. PSR-18 defines that as "no response received", but here the status and headers did arrive, so a capture or refund may have gone through. It must not look like a safe-to-retry network error. Adding a PSR-18 interface later stays BC-safe; removing one would not.Evidence
The issue's reproduction (Symfony
MockHttpClient→Psr18Client7.4 → nyholm/psr7 1.8.2, PHP 8.4), with status 200 and 500:RuntimeException: Unable to read stream contents: Connection reset by peer, thrown viadecodeJson()(200) andassertStatusCode()(500). Not aQuickpayException.After:
IncompleteResponseException: The response body could not be read in full [GET https://api.quickpay.net/ping] (status code: 200): Unable to read stream contents: Connection reset by peer. It is aQuickpayException.New tests, through
ScriptedHttpClientplus aNonSeekableStreamtest double:220 tests pass. PHPStan (max), ECS and Rector are clean, and Infection gives MSI 88% / covered 89%.
Merge Danger
Door: Two-way until tagged
Once it's released,
IncompleteResponseExceptionis public API, so removing it would be a 2.0 change.Blast Radius: Every request
Every call now reads the body eagerly.
request()returns a buffered copy of the body instead of the HTTP client's live stream. Quickpay answers are small JSON documents. Existing catch blocks keep working: the new exception extends\RuntimeException, so the Setono/SyliusQuickpayPlugin#175 workaround still catches it.