body
摘要
body
选项用来控制一个请求(比如:PUT, POST, PATCH)的主体部分。
类型
- string
fopen()
resourcePsr\Http\Message\StreamInterface
默认值
None
常量
GuzzleHttp\RequestOptions::BODY
可以设置成下述类型:
string
// You can send requests that use a string as the message body.
$client->request('PUT', '/put', ['body' => 'foo']);
resource returned from
fopen()
// You can send requests that use a stream resource as the body.
$resource = fopen('http://httpbin.org', 'r');
$client->request('PUT', '/put', ['body' => $resource]);
Psr\Http\Message\StreamInterface
// You can send requests that use a Guzzle stream object as the body
$stream = GuzzleHttp\Psr7\stream_for('contents...');
$client->request('POST', '/post', ['body' => $stream]);