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.
 
 

32 lines
574 B

package httputil
import (
"strings"
)
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)
}
right1 := strings.Index(contentType, ",")
if right1 > 0 && right1 < right {
right = right1
}
if right < left {
return ""
}
return contentType[left+1 : right]
}