3
namespace GuzzleHttp\Post;
5
use GuzzleHttp\Message\RequestInterface;
6
use GuzzleHttp\Stream\StreamInterface;
9
* Represents a POST body that is sent as either a multipart/form-data stream
10
* or application/x-www-urlencoded stream.
12
interface PostBodyInterface extends StreamInterface, \Countable
15
* Apply headers to the request appropriate for the current state of the object
17
* @param RequestInterface $request Request
19
public function applyRequestHeaders(RequestInterface $request);
22
* Set a specific field
24
* @param string $name Name of the field to set
25
* @param string|array $value Value to set
29
public function setField($name, $value);
32
* Set the aggregation strategy that will be used to turn multi-valued
33
* fields into a string.
35
* The aggregation function accepts a deeply nested array of query string
36
* values and returns a flattened associative array of key value pairs.
38
* @param callable $aggregator
40
public function setAggregator(callable $aggregator);
43
* Set to true to force a multipart upload even if there are no files.
45
* @param bool $force Set to true to force multipart uploads or false to
50
public function forceMultipartUpload($force);
53
* Replace all existing form fields with an array of fields
55
* @param array $fields Associative array of fields to set
59
public function replaceFields(array $fields);
62
* Get a specific field by name
64
* @param string $name Name of the POST field to retrieve
68
public function getField($name);
71
* Remove a field by name
73
* @param string $name Name of the field to remove
77
public function removeField($name);
80
* Returns an associative array of names to values or a query string.
82
* @param bool $asString Set to true to retrieve the fields as a query
85
* @return array|string
87
public function getFields($asString = false);
90
* Returns true if a field is set
92
* @param string $name Name of the field to set
96
public function hasField($name);
99
* Get all of the files
101
* @return array Returns an array of PostFileInterface objects
103
public function getFiles();
106
* Get a POST file by name.
108
* @param string $name Name of the POST file to retrieve
110
* @return PostFileInterface|null
112
public function getFile($name);
115
* Add a file to the POST
117
* @param PostFileInterface $file File to add
121
public function addFile(PostFileInterface $file);
124
* Remove all files from the collection
128
public function clearFiles();