Add optionally an alternative body

@param string $content
@param string $contentType optional
@param string $charset optional

@return $this
551268
public function contentAlternative($content, $contentType = null, $charset = null)
    {
        $this->getSwiftMessage()->addPart($content, $contentType, $charset);

        return $this;
    }
111571
public function setContentType($mimeType, $charset = null)
    {
        static $mimes = [];

        if (empty($mimes)) {
            $mimes = require(str_replace('Http', 'Config', __DIR__) . DIRECTORY_SEPARATOR . 'Mimes.php');
        }

        if (strpos($mimeType, '/') === false) {
            $extension = ltrim($mimeType, '.');
            // Is this extension supported?
            if (isset($mimes[ $extension ])) {
                $mimeType =& $mimes[ $extension ];
                if (is_array($mimeType)) {
                    $mimeType = current($mimeType);
                }
            }
        }

        $this->mimeType = $mimeType;

        $this->addHeader(
            'Content-Type',
            $mimeType
            . (empty($charset) ? '' : '; charset=' . $charset)
        );

        return $this;
    }
1267642
public Request setContent(String text, ContentType contentType) {
        entity = new StringEntity(text, contentType);
        return this;
    }
673164
public function addOption(string $content, string $value) : Option
    {
        $option = new Option($content, $value);
        $this->elements[] = $option;

        return $option;
    }
661714
public KieServerHttpRequest contentType(final String contentType, final String charset ) {
        if( charset != null && charset.length() > 0 ) {
            final String separator = "; " + PARAM_CHARSET + '=';
            return header(CONTENT_TYPE, contentType + separator + charset);
        } else
            return header(CONTENT_TYPE, contentType);
    }
1077214
public function setBody(string $body, string $contentType = 'text/html')
    {
        $this->setHeader('Content-Type', $contentType);
        $this->body = $body;
        return $this;
    }
936903
public function appendBody($content, $name = null)
    {
        if ((null === $name) || !is_string($name)) {
            if (isset($this->_body['default'])) {
                $this->_body['default'] .= (string) $content;
            } else {
                return $this->append('default', $content);
            }
        } elseif (isset($this->_body[$name])) {
            $this->_body[$name] .= (string) $content;
        } else {
            return $this->append($name, $content);
        }

        return $this;
    }
1043383
public function setContent($content)
    {
        $this->contents = trim($content);

        $this->parsedContents = null;
        return $this;
    }
1066705
public function addPart($body, $contentType = null, $charset = null)
    {
        return $this->attach((new Swift_MimePart($body, $contentType, $charset))->setEncoder($this->getEncoder()));
    }
610483
public void setContentType(String contentType) 
    {
        if (isCommitted())
            return;
        
        if (contentType==null)
        {
            _mimeType=null;
            _header.remove(HttpFields.__ContentType);
        }
        else
        {
            // Look for encoding in contentType
            int i0=contentType.indexOf(';');
            
            if (i0>0)
            {
                // Strip params off mimetype
                _mimeType=contentType.substring(0,i0).trim();
                
                // Look for charset
                int i1=contentType.indexOf("charset=",i0);
                if (i1>=0)
                {
                    i1+=8;
                    int i2 = contentType.indexOf(' ',i1);
                    _characterEncoding = (0<i2)
                    ? contentType.substring(i1,i2)
                                    : contentType.substring(i1);
                    _characterEncoding = QuotedStringTokenizer.unquote(_characterEncoding);
                }
                else // No encoding in the params.
                {
                    if (_characterEncoding!=null)
                        // Add any previously set encoding.
                        contentType+=";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
                }
            }
            else // No encoding and no other params
            {
                _mimeType=contentType;
                // Add any previously set encoding.
                if (_characterEncoding!=null)
                    contentType+=";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
            }
            
            _header.put(HttpFields.__ContentType,contentType);
        }
    }
552753
public function setCharset($charset = null)
    {
        if (! is_null($charset)) {
            $this->charset = $charset;
        } elseif (defined('THEMOSIS_CHARSET')) {
            $this->charset = THEMOSIS_CHARSET;
        } elseif (function_exists('get_bloginfo')) {
            $this->charset = get_bloginfo('charset');
        }

        return $this;
    }
852809
public function addCompatibleContentType($contentType)
    {
        if (!\in_array($contentType, $this->compatibleContentTypes, true)) {
            $this->compatibleContentTypes[] = $contentType;
        }
    }
349118
public static function create($contentType, $content = '', $bodyStream = null)
    {
        /* @var ResponseInterface|MockInterface $response */
        $response = Mockery::mock(ResponseInterface::class);

        $response
            ->shouldReceive('getHeader')
            ->with('content-type')
            ->andReturn([
                $contentType,
            ]);

        $response
            ->shouldReceive('getHeaderLine')
            ->with('content-type')
            ->andReturn($contentType);

        if (empty($bodyStream)) {
            /* @var StreamInterface|Mock $bodyStream */
            $bodyStream = Mockery::mock(StreamInterface::class);
            $bodyStream
                ->shouldReceive('__toString')
                ->andReturn($content);
        }

        $response
            ->shouldReceive('getBody')
            ->andReturn($bodyStream);

        return $response;
    }
200042
public function contentType(string $content_type, string $charset = '')
    {
        $header = new ContentType($content_type);

        if (!empty($charset)) {
            $header->setCharset($charset);
        }

        $this->addHeader($header);
    }
471190
protected function createResponse($content, $contentType)
    {
        $resp = new HttpResponse();

        $resp->setStatusCode(200)
             ->setContent($content);
        $resp->getHeaders()->addHeaders(array(
            'Content-Length'    => strlen($content),
            'Content-Type'      => $contentType
        ));
        return $resp;
    }
1234871
public function withContentType($contentType, $charset = null)
    {
        if (is_null($charset)) {
            return $this->withHeader('Content-Type', $contentType);
        }

        return $this->withHeader('Content-Type', $contentType . '; charset=' . $charset);
    }
870022
public function setContent(string $content = null): ResponseContextAbstract
    {
        if (is_null($content)) {
            return $this;
        }

        $this->assertIsValid($content);

        $this->content = $content;

        return $this;
    }