Skip to content

Commit d601255

Browse files
Update http_client.rst
Added `$formData->bodyToString()`, see symfony/symfony#34951 (comment)
1 parent e9c6102 commit d601255

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

http_client.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,15 @@ according to the ``multipart/form-data`` content-type. The
631631
'body' => $formData->bodyToIterable(),
632632
]);
633633

634+
HttpClient will stream the upload of the body by default. This might not work with all
635+
servers, resulting in HTTP status code 411 ("Length Required") cause there is no
636+
``Content-Length`` header. In this case, just turn the body into a string::
637+
638+
$client->request('POST', 'https://...', [
639+
// ...
640+
'body' => $formData->bodyToString(),
641+
]);
642+
634643
Cookies
635644
~~~~~~~
636645

0 commit comments

Comments
 (0)