Neos\Flow\Http\AbstractMessage::setContent PHP Method

setContent() public method

Explicitly sets the content of the message body
public setContent ( string $content ) : self
$content string The body content
return self This message, for method chaining
    public function setContent($content)
    {
        $this->content = $content;
        return $this;
    }

Usage Example

Esempio n. 1
0
 /**
  * Explicitly sets the content of the request body
  *
  * In most cases, content is just a string representation of the request body.
  * In order to reduce memory consumption for uploads and other big data, it is
  * also possible to pass a stream resource. The easies way to convert a local file
  * into a stream resource is probably: $resource = fopen('file://path/to/file', 'rb');
  *
  * @param string|resource $content The body content, for example arguments of a PUT request, or a stream resource
  * @return void
  * @api
  */
 public function setContent($content)
 {
     if (is_resource($content) && get_resource_type($content) === 'stream' && stream_is_local($content)) {
         $streamMetaData = stream_get_meta_data($content);
         $this->headers->set('Content-Length', filesize($streamMetaData['uri']));
         $this->headers->set('Content-Type', MediaTypes::getMediaTypeFromFilename($streamMetaData['uri']));
     }
     parent::setContent($content);
 }