Sets ``Content-Disposition`` header.

    disptype is a disposition type: inline, attachment, form-data.
    Should be valid extension token (see RFC 2183)

    params is a dict with disposition params.
427942
def content_disposition_header(disptype: str,
                               quote_fields: bool=True,
                               **params: str) -> str:
    
    if not disptype or not (TOKEN > set(disptype)):
        raise ValueError('bad content disposition type {!r}'
                         ''.format(disptype))

    value = disptype
    if params:
        lparams = []
        for key, val in params.items():
            if not key or not (TOKEN > set(key)):
                raise ValueError('bad content disposition parameter'
                                 ' {!r}={!r}'.format(key, val))
            qval = quote(val, '') if quote_fields else val
            lparams.append((key, '"%s"' % qval))
            if key == 'filename':
                lparams.append(('filename*', "utf-8''" + qval))
        sparams = '; '.join('='.join(pair) for pair in lparams)
        value = '; '.join((value, sparams))
    return value
992283
public void setContentType(String contentType) 
    {
        if (isCommitted() || contentType==null)
            return;
        
        int semi=contentType.indexOf(';');
        if (semi>0)
        {
            int charset0=contentType.indexOf("charset=",semi);
            if (charset0>0)
            {
                if (_outputState==WRITER_OUT)
                {
                    // need to strip charset= from params
                    int charset1=contentType.indexOf(' ',charset0);
                    
                    if ((charset0==semi+1 && charset1<0) ||
                        (charset0==semi+2 && charset1<0 && contentType.charAt(semi+1)==' ' ))
                        _httpResponse.setContentType(contentType.substring(0,semi));
                    else if (charset1<0)
                        _httpResponse.setContentType(contentType.substring(0, charset0).trim());
                    else
                        _httpResponse.setContentType(contentType.substring(0, charset0)+contentType.substring(charset1));
                }
                else
                {
                    _charEncodingSetInContentType=true;
                    _httpResponse.setContentType(contentType);
                }
            }
            else
                _httpResponse.setContentType(contentType);
        }
        else
            _httpResponse.setContentType(contentType);
        
        if (_locale!=null)
            setLocale(_locale);
    }
294108
public Part<T> setContentType(MediaType contentType) {
        headers.add(HttpHeaders.CONTENT_TYPE, contentType.toString());
        return this;
    }
856846
def set_response_content_type(self):
        
        if self.response.body:
            ct = self.type
            if self.charset:
                ct += '; charset=' + self.charset
            self.response.headers['Content-Type'] = ct
        elif 'Content-Type' in self.response.headers:
            del self.response.headers['Content-Type']
599215
def content_type(self, mime_type: Optional[MimeType] = None) -> str:
        
        fmt = self.__file.mime_type(type_=mime_type)
        return 'Content-Type: {}'.format(fmt)
1097327
def set_content_type(self, content_type):
        
        self.policies.append(('eq', '$Content-Type', content_type))
        self.form_data['Content-Type'] = content_type
255396
def get_content_type (headers):
    
    ptype = headers.get('Content-Type', 'application/octet-stream')
    if ";" in ptype:
        # split off not needed extension info
        ptype = ptype.split(';')[0]
    return ptype.strip().lower()
1337816
def set_content_type(self):
        
        if self.object_name and not self.content_type:
            # XXX nothing is currently done with the encoding... we may
            # need to in the future
            self.content_type, encoding = mimetypes.guess_type(
                self.object_name, strict=False)
1081911
def content_type(self, content_type):
        
        allowed_values = ["application/json", "text/html", "text/plain", "application/x-www-form-urlencoded", ""]  # noqa: E501
        if content_type not in allowed_values:
            raise ValueError(
                "Invalid value for `content_type` ({0}), must be one of {1}"  # noqa: E501
                .format(content_type, allowed_values)
            )

        self._content_type = content_type
584501
protected function attachAll($disposition_type, $boundary)
    {
        // Return text of body
        $mime = array();
        $cidUniq = array();
        $incl = array();

        // Add all attachments
        foreach ($this->attachment as $attachment) {
            // Check if it is a valid disposition_filter
            if ($attachment[6] == $disposition_type) {
                // Check for string attachment
                $string = '';
                $path = '';
                $bString = $attachment[5];
                if ($bString) {
                    $string = $attachment[0];
                } else {
                    $path = $attachment[0];
                }

                $inclhash = md5(serialize($attachment));
                if (in_array($inclhash, $incl)) {
                    continue;
                }
                $incl[] = $inclhash;
                $name = $attachment[2];
                $encoding = $attachment[3];
                $type = $attachment[4];
                $disposition = $attachment[6];
                $cid = $attachment[7];
                if ($disposition == 'inline' && array_key_exists($cid, $cidUniq)) {
                    continue;
                }
                $cidUniq[$cid] = true;

                $mime[] = sprintf('--%s%s', $boundary, $this->LE);
                //Only include a filename property if we have one
                if (!empty($name)) {
                    $mime[] = sprintf(
                        'Content-Type: %s; name="%s"%s',
                        $type,
                        $this->encodeHeader($this->secureHeader($name)),
                        $this->LE
                    );
                } else {
                    $mime[] = sprintf(
                        'Content-Type: %s%s',
                        $type,
                        $this->LE
                    );
                }
                // RFC1341 part 5 says 7bit is assumed if not specified
                if ($encoding != '7bit') {
                    $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, $this->LE);
                }

                if ($disposition == 'inline') {
                    $mime[] = sprintf('Content-ID: <%s>%s', $cid, $this->LE);
                }

                // If a filename contains any of these chars, it should be quoted,
                // but not otherwise: RFC2183 & RFC2045 5.1
                // Fixes a warning in IETF's msglint MIME checker
                // Allow for bypassing the Content-Disposition header totally
                if (!(empty($disposition))) {
                    $encoded_name = $this->encodeHeader($this->secureHeader($name));
                    if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $encoded_name)) {
                        $mime[] = sprintf(
                            'Content-Disposition: %s; filename="%s"%s',
                            $disposition,
                            $encoded_name,
                            $this->LE . $this->LE
                        );
                    } else {
                        if (!empty($encoded_name)) {
                            $mime[] = sprintf(
                                'Content-Disposition: %s; filename=%s%s',
                                $disposition,
                                $encoded_name,
                                $this->LE . $this->LE
                            );
                        } else {
                            $mime[] = sprintf(
                                'Content-Disposition: %s%s',
                                $disposition,
                                $this->LE . $this->LE
                            );
                        }
                    }
                } else {
                    $mime[] = $this->LE;
                }

                // Encode as string attachment
                if ($bString) {
                    $mime[] = $this->encodeString($string, $encoding);
                    if ($this->isError()) {
                        return '';
                    }
                    $mime[] = $this->LE . $this->LE;
                } else {
                    $mime[] = $this->encodeFile($path, $encoding);
                    if ($this->isError()) {
                        return '';
                    }
                    $mime[] = $this->LE . $this->LE;
                }
            }
        }

        $mime[] = sprintf('--%s--%s', $boundary, $this->LE);

        return implode('', $mime);
    }
423461
private void setContentTypeHeader(HttpResponse response, URLConnection resUrlConnection) {
    MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
    String resName = resUrlConnection.getURL().getFile();
    response.headers().set(HttpHeaderNames.CONTENT_TYPE, mimeTypesMap.getContentType(resName));
  }
1057186
private function setHeaders($type = self::CONTENT_APP_STREAM, $suggestedFileName = '', $disposition = 'attachment', $ignore_user_abort = false)
    {
        // Set Response Headers
        $this->headers->set('Content-Type', $type);
        $this->headers->set('Content-Disposition', ($disposition ?: 'attachment') . '; filename=' . $suggestedFileName);

        // Set buffer settings
        ignore_user_abort($ignore_user_abort);

        return $this;
    }
710226
def download(self, data, filename, content_type="application/pdf"):
        
        self.request.response.setHeader(
            "Content-Disposition", "inline; filename=%s" % filename)
        self.request.response.setHeader("Content-Type", content_type)
        self.request.response.setHeader("Content-Length", len(data))
        self.request.response.setHeader("Cache-Control", "no-store")
        self.request.response.setHeader("Pragma", "no-cache")
        self.request.response.write(data)
1362235
function (request, callback) {
            var form = request.form;
            form.target = "xIFrame" + request.id;
            form.action = request.url;
            form.method = request.method;
            if (request.headers["Content-Type"]) {
                try {
                    // in IE 8, setting form.enctype directly does not work
                    // form.setAttribute works better (check PTR 07049566)
                    form.setAttribute("enctype", request.headers["Content-Type"]);
                } catch (ex) {
                    // This might throw an exception in IE if the content type is invalid.
                }
            }
            try {
                form.submit();
            } catch (er) {
                this.$logError(this.ERROR_DURING_SUBMIT, null, er);
                this._deleteRequest(request);
                ariaCoreIO._handleTransactionResponse({
                    conn : {
                        status : 0,
                        responseText : null,
                        getAllResponseHeaders : function () {}
                    },
                    transaction : request.id
                }, callback, true);
            }
        }
1373377
private void setMultipart(String contentType) {
        String[] dataBoundary = HttpPostRequestDecoder.getMultipartDataBoundary(contentType);
        if (dataBoundary != null) {
            multipartDataBoundary = dataBoundary[0];
            if (dataBoundary.length > 1 && dataBoundary[1] != null) {
                charset = Charset.forName(dataBoundary[1]);
            }
        } else {
            multipartDataBoundary = null;
        }
        currentStatus = MultiPartStatus.HEADERDELIMITER;
    }
689959
def content_disposition(self) -> Optional[ContentDispositionHeader]:
        """"""
        try:
            return cast(ContentDispositionHeader,
                        self[b'content-disposition'][0])
        except (KeyError, IndexError):
            return None
660493
function setContentType( $type = false, $charset = false,
                             $transferEncoding = false, $disposition = false, $boundary = false )
    {
        if ( $type )
        {
            $this->ContentType['type'] = $type;
        }
        if ( $charset )
            $this->ContentType['charset'] = $charset;
        if ( $transferEncoding )
            $this->ContentType['transfer-encoding'] = $transferEncoding;
        if ( $disposition )
            $this->ContentType['disposition'] = $disposition;
        if ( $boundary )
            $this->ContentType['boundary'] = $boundary;

        // if the body was already defined
        if ( $this->Mail->body instanceof ezcMailText )
        {
            // if the content-type is in the form of e.g. 'text/plain'
            if ( strpos( $this->ContentType['type'] ,'/' ) !== false )
            {
                list( $type, $subType ) = explode( '/', $this->ContentType['type'] );
                $this->Mail->body->subType = $subType;
            }
        }
    }