MediaType

is a parsed media type — the value of a Content-Type header, such as multipart/form-data; boundary=abc. type and subtype are lower-cased; params maps lower-cased parameter names to their values with any surrounding quotes removed.

copy

instantiate

(Fn [(Ref MediaType a)] MediaType)

copies a MediaType.

delete

instantiate

(Fn [MediaType] ())

deletes a MediaType. Should usually not be called manually.

init

instantiate

(Fn [String, String, (Map String String)] MediaType)

creates a MediaType.

mime

defn

(Fn [(Ref MediaType a)] String)

                        (mime mt)
                    

returns the type/subtype string, without any parameters.

param

defn

(Fn [(Ref MediaType a), (Ref String b)] (Maybe String))

                        (param mt name)
                    

looks up a parameter by name (case-insensitive), returning (Maybe String).

params

instantiate

(Fn [(Ref MediaType a)] (Ref (Map String String) a))

gets the params property of a MediaType.

parse

defn

(Fn [(Ref String a)] (Result MediaType String))

                        (parse s)
                    

parses a Content-Type header value into a MediaType. Fails when there is no type/subtype.

parse-params

defn

(Fn [(Ref String a)] (Map String String))

                        (parse-params s)
                    

parses an RFC 2045 parameter list — the ; k=v; k2="quoted" tail shared by Content-Type and Content-Disposition — into a map from lower-cased parameter names to unquoted values. Any leading segment without an = (the media type or disposition itself) is ignored, so the whole header value may be passed.

prn

instantiate

(Fn [(Ref MediaType a)] String)

converts a MediaType to a string.

set-params

instantiate

(Fn [MediaType, (Map String String)] MediaType)

sets the params property of a MediaType.

set-params!

instantiate

(Fn [(Ref MediaType a), (Map String String)] ())

sets the params property of a MediaType in place.

set-subtype

instantiate

(Fn [MediaType, String] MediaType)

sets the subtype property of a MediaType.

set-subtype!

instantiate

(Fn [(Ref MediaType a), String] ())

sets the subtype property of a MediaType in place.

set-type

instantiate

(Fn [MediaType, String] MediaType)

sets the type property of a MediaType.

set-type!

instantiate

(Fn [(Ref MediaType a), String] ())

sets the type property of a MediaType in place.

str

instantiate

(Fn [(Ref MediaType a)] String)

converts a MediaType to a string.

subtype

instantiate

(Fn [(Ref MediaType a)] (Ref String a))

gets the subtype property of a MediaType.

type

instantiate

(Fn [(Ref MediaType a)] (Ref String a))

gets the type property of a MediaType.

update-params

instantiate

(Fn [MediaType, (Ref (Fn [(Map String String)] (Map String String) a) b)] MediaType)

updates the params property of a MediaType using a function f.

update-subtype

instantiate

(Fn [MediaType, (Ref (Fn [String] String a) b)] MediaType)

updates the subtype property of a MediaType using a function f.

update-type

instantiate

(Fn [MediaType, (Ref (Fn [String] String a) b)] MediaType)

updates the type property of a MediaType using a function f.