private function prepareHeaders($name, StreamInterface $stream, $filename, array &$headers)
    {
        $hasFilename = '0' === $filename || $filename;

        // Set a default content-disposition header if one was not provided
        if (!$this->hasHeader($headers, 'content-disposition')) {
            $headers['Content-Disposition'] = sprintf('form-data; name="%s"', $name);
            if ($hasFilename) {
                $headers['Content-Disposition'] .= sprintf('; filename="%s"', $this->basename($filename));
            }
        }

        // Set a default content-length header if one was not provided
        if (!$this->hasHeader($headers, 'content-length')) {
            if ($length = $stream->getSize()) {
                $headers['Content-Length'] = (string) $length;
            }
        }

        // Set a default Content-Type if one was not provided
        if (!$this->hasHeader($headers, 'content-type') && $hasFilename) {
            if ($type = $this->getMimetypeHelper()->getMimetypeFromFilename($filename)) {
                $headers['Content-Type'] = $type;
            }
        }
    }
private function prepareHeaders($name, StreamInterface $stream, $filename, array &$headers)
    {
        $hasFilename = '0' === $filename || $filename;

        // Set a default content-disposition header if one was not provided
        if (!$this->hasHeader($headers, 'content-disposition')) {
            $headers['Content-Disposition'] = sprintf('form-data; name="%s"', $name);
            if ($hasFilename) {
                $headers['Content-Disposition'] .= sprintf('; filename="%s"', $this->basename($filename));
            }
        }

        // Set a default content-length header if one was not provided
        if (!$this->hasHeader($headers, 'content-length')) {
            if ($length = $stream->getSize()) {
                $headers['Content-Length'] = (string) $length;
            }
        }

        // Set a default Content-Type if one was not provided
        if (!$this->hasHeader($headers, 'content-type') && $hasFilename) {
            if ($type = $this->getMimetypeHelper()->getMimetypeFromFilename($filename)) {
                $headers['Content-Type'] = $type;
            }
        }
    }
private function prepareHeaders ( $ name , StreamInterface $ stream , $ filename , array & $ headers ) { $ hasFilename = '0' === $ filename || $ filename ; // Set a default content-disposition header if one was not provided if ( ! $ this -> hasHeader ( $ headers , 'content-disposition' ) ) { $ headers [ 'Content-Disposition' ] = sprintf ( 'form-data; name="%s"' , $ name ) ; if ( $ hasFilename ) { $ headers [ 'Content-Disposition' ] .= sprintf ( '; filename="%s"' , $ this -> basename ( $ filename ) ) ; } } // Set a default content-length header if one was not provided if ( ! $ this -> hasHeader ( $ headers , 'content-length' ) ) { if ( $ length = $ stream -> getSize ( ) ) { $ headers [ 'Content-Length' ] = ( string ) $ length ; } } // Set a default Content-Type if one was not provided if ( ! $ this -> hasHeader ( $ headers , 'content-type' ) && $ hasFilename ) { if ( $ type = $ this -> getMimetypeHelper ( ) -> getMimetypeFromFilename ( $ filename ) ) { $ headers [ 'Content-Type' ] = $ type ; } } }
Add extra headers if they are missing.

@param string          $name
@param StreamInterface $stream
@param string          $filename
@param array           &$headers
Add extra headers if they are missing .