mirror of
https://github.com/moby/moby.git
synced 2026-08-09 09:33:50 +00:00
full diff: https://github.com/moby/buildkit/compare/d1e5d1a8f771...v0.27.0-rc1 Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
35 lines
652 B
Go
35 lines
652 B
Go
// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package runtime
|
|
|
|
import (
|
|
"mime"
|
|
"net/http"
|
|
|
|
"github.com/go-openapi/errors"
|
|
)
|
|
|
|
// ContentType parses a content type header
|
|
func ContentType(headers http.Header) (string, string, error) {
|
|
ct := headers.Get(HeaderContentType)
|
|
orig := ct
|
|
if ct == "" {
|
|
ct = DefaultMime
|
|
}
|
|
if ct == "" {
|
|
return "", "", nil
|
|
}
|
|
|
|
mt, opts, err := mime.ParseMediaType(ct)
|
|
if err != nil {
|
|
return "", "", errors.NewParseError(HeaderContentType, "header", orig, err)
|
|
}
|
|
|
|
if cs, ok := opts[charsetKey]; ok {
|
|
return mt, cs, nil
|
|
}
|
|
|
|
return mt, "", nil
|
|
}
|