HasBody
trait HasBody
Every request and pending request uses this trait, so body traits need no upstream HasBody contract or
ChecksForHasBody check.
Properties
| protected BodyRepository|null | $bodyRepository | The request body repository. |
Methods
Set the raw request body.
Use a multipart request body, keeping any existing multipart values.
Attach a multipart value to the request.
Get the resolved request body value.
Determine if the request has a body repository.
Copy the body repository for a pending request.
Resolve the default body repository.
Get the request body repository.
Details
at line 36
HasBody
withBody(mixed $content, string|null $contentType = 'application/json')
Set the raw request body.
at line 55
HasBody
asJson(array $data = [])
Use a JSON request body.
at line 68
HasBody
asForm(array $data = [])
Use a URL-encoded form request body.
at line 80
HasBody
asMultipart()
Use a multipart request body, keeping any existing multipart values.
at line 97
HasBody
attach(array|string $name, mixed $contents = '', string|null $filename = null, array $headers = [])
Attach a multipart value to the request.
at line 129
HasBody
withData(array $data)
Merge structured values into the request body.
A multipart body receives each value as an appended field.
at line 154
mixed
body()
Get the resolved request body value.
at line 162
bool
hasBody()
Determine if the request has a body repository.
at line 172
final BodyRepository|null
copyBodyRepository()
| internal |
Copy the body repository for a pending request.
at line 182
protected BodyRepository|null
defaultBodyRepository()
Resolve the default body repository.
at line 190
protected BodyRepository|null
bodyRepository()
Get the request body repository.