Set body with stream acceptance
@param resource|string $body Request body
@throws InvalidArgumentException
13170
public function setBody($body)
    {
        if (is_string($body)) {
            return $this->setStringBody($body);
        }

        if (!is_resource($body)) {
            throw new InvalidArgumentException('Body must be a stream !');
        }
        if (!stream_is_local($body)) {
            throw new InvalidArgumentException('Body must be a local stream !');
        }

        rewind($body);
        $this->body = $body;
    }
433504
public function setBody($body)
    {
        if ($body !== false && (empty($body) || !is_array($body) || (count($body) % 2) !== 0)) {
            throw new InvalidResponseException($this->command, $body);
        }
        parent::setBody($body);
    }
1178498
public function setBody($body, $contentType = null, $charset = null)
    {
        if (isset($charset)) {
            $this->setCharset($charset);
        }
        $body = $this->convertString($body);

        parent::setBody($body, $contentType);

        return $this;
    }
874892
public function setBody($body)
    {
        $this->code = array(new CodeLineGenerator($body, $this->getIndentationLevel(), $this->getIndentationString()));

        return $this;
    }
668929
public function createStream($body = null)
    {
        if ($body instanceof StreamInterface)
        {
            return $body;
        }

        if (\is_resource($body))
        {
            return Stream::createFromResource($body);
        }

        return Stream::create($body ?? '');
    }
16567
private function normalizeBody($body = null)
    {
        $body = $body ? $body : new Stream(fopen('php://temp', 'r+'));
        if (is_string($body)) {
            $memoryStream = fopen('php://temp', 'r+');
            fwrite($memoryStream, $body);
            rewind($memoryStream);
            $body = new Stream($memoryStream);
        } elseif (!($body instanceof StreamInterface)) {
            throw new InvalidArgumentException(
                'Body must be a string, null or implement Psr\Http\Message\StreamInterface'
            );
        }

        return $body;
    }
1038183
public function setBody(?MessageBody $body) : Message
    {
        $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;
    }
127881
public function setBody($body = null, $clearSid = true)
    {
        if ($clearSid) {
            $body = $this->_clearSidFromBody($body);
        }

        $this->set("Body", $body);
    }
259836
protected function setBody($body = null)
    {
        parent::setBody($body);

        if (is_array($body) || is_object($body)) {
            $this->post = (array) $body;
        } else {
            $this->post = [];
        }
    }
748788
public function withBody(StreamInterface $body) : self
    {
        $new = clone $this;

        return $new->setResponse($this->response->withBody($body));
    }
275509
public function setResource( $resource )
	{
		if( !is_resource( $resource ) )
			throw new InvalidArgumentException( 'Must be a valid image resource' );
		if( $this->resource )
			imagedestroy( $this->resource );

		$this->resource	= $resource;
		$this->width	= imagesx( $resource );
		$this->height	= imagesy( $resource );

		if( function_exists( 'imageantialias' ) )
			imageantialias( $this->resource, TRUE );

		imagealphablending( $this->resource, FALSE );											//  disable alpha blending in favour to
		imagesavealpha( $this->resource, TRUE );											//  copying the complete alpha channel
	}
1341661
protected function sendBody(Stream $body)
    {
        // I don't trust that this will be at the beginning of the stream, so reset.
        $body->rewind();

        // writing to an arbitrary stream.
        // @todo Use stream operations to make this more robust and allow
        $bytes = 0;
        if ($bytes = $body->getSize() && $bytes < 500) {
            print $body->getContents();

        } else {
            while (!$body->eof()) {
                $data = $body->read(1024);
                print $data;
            }
        }
    }
820904
public function setBody($body, $content_type = false){
	
		// clear old body data
		$this->post->clear();
		$this->files->clear();
		
		// is this form data?
		if(is_array($body)){
			$body = http_build_query($body);
		}
		
		$this->body = (string)$body;
		
		// plain text should be: text/plain; charset=UTF-8
		if($content_type){
			$this->headers->set('content-type', $content_type);
		}
		
		// do it!
		$this->prepare();
	}
1103505
protected function sendBody($body):void
    {
        if (is_resource($body)) {
            fpassthru($body);
            fclose($body);
        }
        else {
            echo $body;
        }
    }
1228716
public function withBody(StreamInterface $body)
    {
        if ($this->complete) {
            return $this;
        }

        $new = $this->psrResponse->withBody($body);
        return new self($new);
    }
503142
public function setStream($stream = null)
    {
        // String passed in? Try converting it to a stream
        if (is_string($stream)) {
            $stream = @fopen($stream, 'a');
        }

        // Make sure the stream is a resource
        if (!is_resource($stream)) {
            throw new \InvalidArgumentException('Invalid Stream');
        }

        // Store it
        $this->stream = $stream;

        // Afford chaining
        return $this;
    }
932054
public static function create($body = ''): StreamInterface
    {
        if ($body instanceof StreamInterface) {
            return $body;
        }

        if (\is_string($body)) {
            $resource = \fopen('php://temp', 'rw+');
            \fwrite($resource, $body);
            $body = $resource;
        }

        if (\is_resource($body)) {
            $new = new self();
            $new->stream = $body;
            $meta = \stream_get_meta_data($new->stream);
            $new->seekable = $meta['seekable'];
            $new->readable = isset(self::READ_WRITE_HASH['read'][$meta['mode']]);
            $new->writable = isset(self::READ_WRITE_HASH['write'][$meta['mode']]);
            $new->uri = $new->getMetadata('uri');

            return $new;
        }

        throw new \InvalidArgumentException('First argument to Stream::create() must be a string, resource or StreamInterface.');
    }