From 14384d72c9e917ca76faf2b51d0999315e53a8ee Mon Sep 17 00:00:00 2001 From: AMPHP Bot Date: Sat, 24 Feb 2024 22:55:08 +0100 Subject: [PATCH] Sync http-client.md --- http-client.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/http-client.md b/http-client.md index 69e3149..e8a2148 100644 --- a/http-client.md +++ b/http-client.md @@ -115,17 +115,17 @@ $request->setBody("foobar"); #### Request Bodies -`Request::setBody($body)` allows changing the request body. Accepted types are `string`, `null`, and `RequestBody`. `string` and `null` are automatically converted to an instance of `RequestBody`. +`Request::setBody($body)` allows changing the request body. Accepted types are `string`, `null`, and `HttpContent`. `string` and `null` are automatically converted to an instance of `HttpContent`. {:.note} -> `RequestBody` is basically a factory for request bodies. We cannot simply accept streams here, because a request body might have to be sent again on a redirect / retry. Additionally, `RequestBody` allows the body to set headers, which can be used to automatically set headers such as `Content-Type: application/json` for a `JsonBody`. Note that headers set via `RequestBody::getHeaders()` are only applied if the `Request` doesn't have such a header. This allows overriding the default body header in a request. +> `HttpContent` is basically a factory for request bodies. We cannot simply accept streams here, because a request body might have to be sent again on a redirect / retry. ```php $request = new Request("https://httpbin.org/post", "POST"); $request->setBody("foobar"); ``` -`Request::getBody()` exposes the request body of the given `Request` object and will always return a `RequestBody`. +`Request::getBody()` exposes the request body of the given `Request` object and will always return a `HttpContent`. ### Response