Commit bbdf0e0
committed
minor symfony#58856 [HttpClient] Stream request body in HttplugClient and Psr18Client (KurtThiemann)
This PR was squashed before being merged into the 7.2 branch.
Discussion
----------
[HttpClient] Stream request body in HttplugClient and Psr18Client
| Q | A
| ------------- | ---
| Branch? | 7.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | -
| License | MIT
Currently, `Psr18Client` and `HttplugClient` will simply call `getContents()` on the stream, loading the entire stream content into a string before passing it to the underlying `HttpClient`. When sending a request with a large body, this can lead to the PHP process running out of memory.
This pull request changes both clients to instead pass a Closure that reads from the request body stream to the underlying `HttpClient`.
The HttpClient documentation states that "each time, the closure should return a string smaller than the amount requested as argument", which would mean that if the closure was called requesting a size of 10 bytes, you are only allowed to return at most 9 bytes. I assume that is an inaccuracy in the docs, but please correct me if I'm wrong here.
I'm also not fully sure whether this would be considered a new feature or a bug fix.
Commits
-------
e6d1182 [HttpClient] Stream request body in HttplugClient and Psr18ClientFile tree
2 files changed
+14
-4
lines changed- src/Symfony/Component/HttpClient
2 files changed
+14
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
232 | 237 | | |
233 | | - | |
234 | | - | |
| 238 | + | |
| 239 | + | |
235 | 240 | | |
236 | 241 | | |
237 | 242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
96 | 101 | | |
97 | | - | |
98 | | - | |
| 102 | + | |
| 103 | + | |
99 | 104 | | |
100 | 105 | | |
101 | 106 | | |
| |||
0 commit comments