1: <?php
2:
3: namespace Guzzle\Http\Message;
4:
5: use Guzzle\Http\Exception\RequestException;
6: use Guzzle\Http\EntityBodyInterface;
7: use Guzzle\Http\QueryString;
8:
9: /**
10: * HTTP request that sends an entity-body in the request message (POST, PUT)
11: */
12: interface EntityEnclosingRequestInterface extends RequestInterface
13: {
14: const URL_ENCODED = 'application/x-www-form-urlencoded; charset=utf-8';
15: const MULTIPART = 'multipart/form-data';
16:
17: /**
18: * Set the body of the request
19: *
20: * @param string|resource|EntityBodyInterface $body Body to use in the entity body of the request
21: * @param string $contentType Content-Type to set. Leave null to use an existing
22: * Content-Type or to guess the Content-Type
23: * @param bool $tryChunkedTransfer Try to use chunked Transfer-Encoding
24: *
25: * @return EntityEnclosingRequestInterface
26: * @throws RequestException if the protocol is < 1.1 and Content-Length can not be determined
27: */
28: public function setBody($body, $contentType = null, $tryChunkedTransfer = false);
29:
30: /**
31: * Get the body of the request if set
32: *
33: * @return EntityBodyInterface|null
34: */
35: public function getBody();
36:
37: /**
38: * Get a POST field from the request
39: *
40: * @param string $field Field to retrieve
41: *
42: * @return mixed|null
43: */
44: public function getPostField($field);
45:
46: /**
47: * Get the post fields that will be used in the request
48: *
49: * @return QueryString
50: */
51: public function getPostFields();
52:
53: /**
54: * Set a POST field value
55: *
56: * @param string $key Key to set
57: * @param string $value Value to set
58: *
59: * @return EntityEnclosingRequestInterface
60: */
61: public function setPostField($key, $value);
62:
63: /**
64: * Add POST fields to use in the request
65: *
66: * @param QueryString|array $fields POST fields
67: *
68: * @return EntityEnclosingRequestInterface
69: */
70: public function addPostFields($fields);
71:
72: /**
73: * Remove a POST field or file by name
74: *
75: * @param string $field Name of the POST field or file to remove
76: *
77: * @return EntityEnclosingRequestInterface
78: */
79: public function removePostField($field);
80:
81: /**
82: * Returns an associative array of POST field names to PostFileInterface objects
83: *
84: * @return array
85: */
86: public function getPostFiles();
87:
88: /**
89: * Get a POST file from the request
90: *
91: * @param string $fieldName POST fields to retrieve
92: *
93: * @return array|null Returns an array wrapping an array of PostFileInterface objects
94: */
95: public function getPostFile($fieldName);
96:
97: /**
98: * Remove a POST file from the request
99: *
100: * @param string $fieldName POST file field name to remove
101: *
102: * @return EntityEnclosingRequestInterface
103: */
104: public function removePostFile($fieldName);
105:
106: /**
107: * Add a POST file to the upload
108: *
109: * @param string $field POST field to use (e.g. file). Used to reference content from the server.
110: * @param string $filename Full path to the file. Do not include the @ symbol.
111: * @param string $contentType Optional Content-Type to add to the Content-Disposition.
112: * Default behavior is to guess. Set to false to not specify.
113: *
114: * @return EntityEnclosingRequestInterface
115: */
116: public function addPostFile($field, $filename = null, $contentType = null);
117:
118: /**
119: * Add POST files to use in the upload
120: *
121: * @param array $files An array of POST fields => filenames where filename can be a string or PostFileInterface
122: *
123: * @return EntityEnclosingRequestInterface
124: */
125: public function addPostFiles(array $files);
126:
127: /**
128: * Configure how redirects are handled for the request
129: *
130: * @param bool $strict Set to true to follow strict RFC compliance when redirecting POST requests. Most
131: * browsers with follow a 301-302 redirect for a POST request with a GET request. This is
132: * the default behavior of Guzzle. Enable strict redirects to redirect these responses
133: * with a POST rather than a GET request.
134: * @param int $maxRedirects Specify the maximum number of allowed redirects. Set to 0 to disable redirects.
135: *
136: * @return self
137: */
138: public function configureRedirects($strict = false, $maxRedirects = 5);
139: }
140: