/** * Sets the message body. * * @param \Brick\Http\MessageBody|null $body * * @return static */ public function setBody(MessageBody $body = null) { $this->body = $body; if ($body) { $size = $body->getSize(); if ($size === null) { $this->setHeader('Transfer-Encoding', 'chunked'); $this->removeHeader('Content-Length'); } else { $this->setHeader('Content-Length', (string) $size); $this->removeHeader('Transfer-Encoding'); } } else { $this->removeHeader('Content-Length'); $this->removeHeader('Transfer-Encoding'); } return $this; }