24 require_once
'HTTP/Request2/Response.php';
98 $this->requestBody = $this->request->getBody();
100 if (is_string($this->requestBody)) {
101 $this->contentLength = strlen($this->requestBody);
102 } elseif (is_resource($this->requestBody)) {
103 $stat = fstat($this->requestBody);
104 $this->contentLength = $stat[
'size'];
105 rewind($this->requestBody);
107 $this->contentLength = $this->requestBody->getLength();
108 $headers[
'content-type'] =
'multipart/form-data; boundary=' .
109 $this->requestBody->getBoundary();
110 $this->requestBody->rewind();
113 if (in_array($this->request->getMethod(), self::$bodyDisallowed)
114 || 0 == $this->contentLength
118 if (in_array($this->request->getMethod(), self::$bodyRequired)) {
119 $headers[
'content-length'] = 0;
121 unset($headers[
'content-length']);
124 unset($headers[
'content-type']);
127 if (empty($headers[
'content-type'])) {
128 $headers[
'content-type'] =
'application/x-www-form-urlencoded';
131 if (!isset($headers[
'transfer-encoding'])) {
sendRequest(HTTP_Request2 $request)
calculateRequestLength(&$headers)