You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
574 B

2 years ago
package httputil
2 years ago
import (
"strings"
)
2 years ago
const (
baseContentType = "application"
)
func ContentType(subtype string) string {
return strings.Join([]string{baseContentType, subtype}, "/")
}
func ContentSubtype(contentType string) string {
left := strings.Index(contentType, "/")
if left == -1 {
return ""
}
right := strings.Index(contentType, ";")
if right == -1 {
right = len(contentType)
}
2 years ago
right1 := strings.Index(contentType, ",")
if right1 > 0 && right1 < right {
right = right1
}
2 years ago
if right < left {
return ""
}
return contentType[left+1 : right]
}