The media-types Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The media-types Reference Manual

This is the media-types Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 04:17:59 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

MEDIA-TYPES is a library for querying and comparing media types.

Probably the most useful function is extension-media-type:

(extension-media-type "txt") => "text/plain"

An unknown extension, or no extension, has a media type of application/octet-stream:

(extension-media-type "my-fake-extension") => "application/octet-stream"
(extension-media-type nil) => "application/octet-stream"

(This is nonstandard, but reflects general practice.)

You can also use media-type-extension to query the extension (or extensions) for a media type:

(media-type-extension "application/javascript") => "js"

If a media type has multiple extensions, they are returned as multiple values:

(media-type-extension "image/jpeg") => "jpeg", "jpg", "jpe"

Extensions are not case sensitive:

(extension-media-type "TXT") => "text/plain"

You may pass the extension with or without a leading dot:

(extension-media-type ".txt") => "text/plain"

You can get the extension of a file name with file-name-extension:

(file-name-extension "file.txt") => "txt"

Or just get the media type of the file directly:

(file-name-media-type "file.txt") => "text/plain"
(file-name-media-type #p"file.txt") => "text/plain"

A file name without an extension has a media type of application/octet-stream:

(file-name-media-type "file") => "application/octet-stream"

However, if you want to test whether a file is of a specific media type, you should use file-name-media-typep.

(file-name-media-typep "file.xml" "application/xml") => t
(file-name-media-typep "file.svg" "application/xml") => t

file-name-media-typep uses media-subtypep, which has a sophisticated understanding of media types:

(media-subtypep "text/plain" "*/*") => t
(media-subtypep "text/plain" "text/*") => t

;; All media types are effectively subtypes of application/octet-stream.
(media-subtypep "text/plain" "application/octet-stream") => t

;; Structured syntax suffixes.
(media-subtypep "image/svg+xml" "application/xml") => t
(media-subtypep "application/vnd.my-format+json" "application/json") => t

;; Media type parameters.
(media-subtypep "application/atom+xml;type=entry" "application/xml") => t
(media-subtypep "application/atom+xml" "application/atom+xml;type=entry") => nil
(media-subtypep "application/atom+xml;charset=UTF8;type=entry"
                "application/atom+xml;type=entry")
=> t

;; The "q" pseudo-parameter is used in HTTP content negotiation.
(media-subtypep "application/json" "*/*;q=0.1") => t

MEDIA-TYPES uses the mime.types from the Apache sources.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 media-types

Author

Paul M. Rodriguez <pmr@ruricolist.com>

License

MIT

Description

Query and compare media types.

Dependencies
Source

media-types.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Next: , Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 media-types.asd

Location

media-types.asd

Systems

media-types (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 media-types/package.lisp

Parent

media-types (system)

Location

package.lisp

Packages

media-types


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 media-types/media-types.lisp

Dependency

package.lisp (file)

Parent

media-types (system)

Location

media-types.lisp

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

3.1.4 media-types/file-extensions.lisp

Dependency

mime.types (file)

Parent

media-types (system)

Location

file-extensions.lisp

Exported Definitions
Internal Definitions

Previous: , Up: Files   [Contents][Index]

3.2 Other


Previous: , Up: Other files   [Contents][Index]

3.2.1 media-types/mime.types

Dependency

media-types.lisp (file)

Parent

media-types (system)

Location

mime.types


Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 media-types

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Compiler macros

Compiler Macro: file-name-media-typep FILE TYPE
Package

media-types

Source

file-extensions.lisp (file)

Compiler Macro: media-subtypep SUBTYPE TYPE
Package

media-types

Source

media-types.lisp (file)

Compiler Macro: media-type= X Y
Package

media-types

Source

media-types.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: extension-media-type EXTENSION
Package

media-types

Source

file-extensions.lisp (file)

Function: file-name-extension FILE
Package

media-types

Source

file-extensions.lisp (file)

Function: file-name-media-type FILE
Package

media-types

Source

file-extensions.lisp (file)

Function: file-name-media-typep FILE TYPE
Package

media-types

Source

file-extensions.lisp (file)

Function: media-subtypep SUBTYPE TYPE
Package

media-types

Source

media-types.lisp (file)

Function: media-type TYPE SUBTYPE &rest PARAMS
Package

media-types

Source

media-types.lisp (file)

Function: media-type-extension TYPE
Package

media-types

Source

file-extensions.lisp (file)

Function: media-type-supers TYPE
Package

media-types

Source

media-types.lisp (file)

Function: media-type-values TYPE
Package

media-types

Source

media-types.lisp (file)

Function: media-type= X Y
Package

media-types

Source

media-types.lisp (file)

Function: parse-media-type TYPE &key ALLOW-PARAMS
Package

media-types

Source

media-types.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Conditions

Condition: invalid-media-type ()
Package

media-types

Source

media-types.lisp (file)

Direct superclasses

error (condition)

Direct slots
Slot: type
Initargs

:type


Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Structures

Structure: media-type ()
Package

media-types

Source

media-types.lisp (file)

Direct superclasses

%read-only-struct (structure)

Direct methods
  • print-object (method)
  • read-only-struct-slot-names (method)
Direct slots
Slot: type
Type

string

Initform

(alexandria.0.dev:required-argument (quote type))

Readers

media-type-type (function)

Writers

(setf media-type-type) (function)

Slot: subtype
Type

string

Initform

(alexandria.0.dev:required-argument (quote media-types::subtype))

Readers

media-type-subtype (function)

Writers

(setf media-type-subtype) (function)

Slot: params
Type

list

Readers

media-type-params (function)

Writers

(setf media-type-params) (function)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Constants

Constant: +storage-for-deflex-var-media-ranges+
Package

media-types

Source

media-types.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Special variables

Special Variable: *extension-media-types*
Package

media-types

Source

file-extensions.lisp (file)

Special Variable: *media-type-extensions*
Package

media-types

Source

file-extensions.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Symbol macros

Symbol Macro: application/cbor
Package

media-types

Source

media-types.lisp (file)

Expansion

media-types::*storage-for-deflex-var-application/cbor*

Symbol Macro: application/fastinfoset
Package

media-types

Source

media-types.lisp (file)

Expansion

media-types::*storage-for-deflex-var-application/fastinfoset*

Symbol Macro: application/json
Package

media-types

Source

media-types.lisp (file)

Expansion

media-types::*storage-for-deflex-var-application/json*

Symbol Macro: application/octet-stream
Package

media-types

Source

media-types.lisp (file)

Expansion

media-types::*storage-for-deflex-var-application/octet-stream*

Symbol Macro: application/vnd.wap.wbxml
Package

media-types

Source

media-types.lisp (file)

Expansion

media-types::*storage-for-deflex-var-application/vnd.wap.wbxml*

Symbol Macro: application/x-www-form-urlencoded
Package

media-types

Source

media-types.lisp (file)

Expansion

media-types::*storage-for-deflex-var-application/x-www-form-urlencoded*

Symbol Macro: application/xml
Package

media-types

Source

media-types.lisp (file)

Expansion

media-types::*storage-for-deflex-var-application/xml*

Symbol Macro: application/zip
Package

media-types

Source

media-types.lisp (file)

Expansion

media-types::*storage-for-deflex-var-application/zip*

Symbol Macro: media-ranges
Package

media-types

Source

media-types.lisp (file)

Expansion

media-types::+storage-for-deflex-var-media-ranges+

Symbol Macro: mime.types
Package

media-types

Source

file-extensions.lisp (file)

Expansion

media-types::*storage-for-deflex-var-mime.types*

Symbol Macro: multipart/form-data
Package

media-types

Source

media-types.lisp (file)

Expansion

media-types::*storage-for-deflex-var-multipart/form-data*

Symbol Macro: suffix-types
Package

media-types

Source

media-types.lisp (file)

Expansion

media-types::*storage-for-deflex-var-suffix-types*


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.4 Functions

Function: check-media-type-valid TYPE &key ALLOW-PARAMS
Package

media-types

Source

media-types.lisp (file)

Function: comment? LINE
Package

media-types

Source

file-extensions.lisp (file)

Function: dotted-extension? X
Package

media-types

Source

file-extensions.lisp (file)

Function: ensure-q TYPE SUBTYPE Q
Package

media-types

Source

media-types.lisp (file)

Function: extract-suffix SUBTYPE
Package

media-types

Source

media-types.lisp (file)

Function: make-extension-to-type-table ()
Package

media-types

Source

file-extensions.lisp (file)

Function: make-media-type &key (TYPE TYPE) (SUBTYPE SUBTYPE) (PARAMS PARAMS)
Package

media-types

Source

media-types.lisp (file)

Function: make-type-to-extension-table ()
Package

media-types

Source

file-extensions.lisp (file)

Function: media-type-p OBJECT
Package

media-types

Source

media-types.lisp (file)

Function: media-type-params INSTANCE
Package

media-types

Source

media-types.lisp (file)

Function: media-type-subtype INSTANCE
Package

media-types

Source

media-types.lisp (file)

Function: media-type-type INSTANCE
Package

media-types

Source

media-types.lisp (file)

Function: media-type-valid TYPE &key ALLOW-PARAMS
Package

media-types

Source

media-types.lisp (file)

Function: parse-media-type-string TYPE &key ALLOW-PARAMS
Package

media-types

Source

media-types.lisp (file)

Function: render-media-type SELF STREAM
Package

media-types

Source

media-types.lisp (file)

Function: render-media-type-params ALIST STREAM
Package

media-types

Source

media-types.lisp (file)

Function: snarf-mime.types ()
Package

media-types

Source

file-extensions.lisp (file)

Function: suffix-type SUFFIX
Package

media-types

Source

media-types.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.5 Types

Type: bare-extension ()
Package

media-types

Source

file-extensions.lisp (file)

Type: dotted-extension ()
Package

media-types

Source

file-extensions.lisp (file)

Type: extension ()
Package

media-types

Source

file-extensions.lisp (file)

Type: file-designator ()
Package

media-types

Source

file-extensions.lisp (file)

Type: media-range ()
Package

media-types

Source

media-types.lisp (file)

Type: media-type-designator ()
Package

media-types

Source

media-types.lisp (file)

Type: no-extension ()
Package

media-types

Source

file-extensions.lisp (file)

Type: type-extensions ()
Package

media-types

Source

file-extensions.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   M   O  
Index Entry  Section

F
File, Lisp, media-types.asd: The media-types<dot>asd file
File, Lisp, media-types/file-extensions.lisp: The media-types/file-extensions<dot>lisp file
File, Lisp, media-types/media-types.lisp: The media-types/media-types<dot>lisp file
File, Lisp, media-types/package.lisp: The media-types/package<dot>lisp file
File, other, media-types/mime.types: The media-types/mime<dot>types file

L
Lisp File, media-types.asd: The media-types<dot>asd file
Lisp File, media-types/file-extensions.lisp: The media-types/file-extensions<dot>lisp file
Lisp File, media-types/media-types.lisp: The media-types/media-types<dot>lisp file
Lisp File, media-types/package.lisp: The media-types/package<dot>lisp file

M
media-types.asd: The media-types<dot>asd file
media-types/file-extensions.lisp: The media-types/file-extensions<dot>lisp file
media-types/media-types.lisp: The media-types/media-types<dot>lisp file
media-types/mime.types: The media-types/mime<dot>types file
media-types/package.lisp: The media-types/package<dot>lisp file

O
Other File, media-types/mime.types: The media-types/mime<dot>types file

Jump to:   F   L   M   O  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   C   D   E   F   M   P   R   S  
Index Entry  Section

C
check-media-type-valid: Internal functions
comment?: Internal functions
Compiler Macro, file-name-media-typep: Exported compiler macros
Compiler Macro, media-subtypep: Exported compiler macros
Compiler Macro, media-type=: Exported compiler macros

D
dotted-extension?: Internal functions

E
ensure-q: Internal functions
extension-media-type: Exported functions
extract-suffix: Internal functions

F
file-name-extension: Exported functions
file-name-media-type: Exported functions
file-name-media-typep: Exported compiler macros
file-name-media-typep: Exported functions
Function, check-media-type-valid: Internal functions
Function, comment?: Internal functions
Function, dotted-extension?: Internal functions
Function, ensure-q: Internal functions
Function, extension-media-type: Exported functions
Function, extract-suffix: Internal functions
Function, file-name-extension: Exported functions
Function, file-name-media-type: Exported functions
Function, file-name-media-typep: Exported functions
Function, make-extension-to-type-table: Internal functions
Function, make-media-type: Internal functions
Function, make-type-to-extension-table: Internal functions
Function, media-subtypep: Exported functions
Function, media-type: Exported functions
Function, media-type-extension: Exported functions
Function, media-type-p: Internal functions
Function, media-type-params: Internal functions
Function, media-type-subtype: Internal functions
Function, media-type-supers: Exported functions
Function, media-type-type: Internal functions
Function, media-type-valid: Internal functions
Function, media-type-values: Exported functions
Function, media-type=: Exported functions
Function, parse-media-type: Exported functions
Function, parse-media-type-string: Internal functions
Function, render-media-type: Internal functions
Function, render-media-type-params: Internal functions
Function, snarf-mime.types: Internal functions
Function, suffix-type: Internal functions

M
make-extension-to-type-table: Internal functions
make-media-type: Internal functions
make-type-to-extension-table: Internal functions
media-subtypep: Exported compiler macros
media-subtypep: Exported functions
media-type: Exported functions
media-type-extension: Exported functions
media-type-p: Internal functions
media-type-params: Internal functions
media-type-subtype: Internal functions
media-type-supers: Exported functions
media-type-type: Internal functions
media-type-valid: Internal functions
media-type-values: Exported functions
media-type=: Exported compiler macros
media-type=: Exported functions

P
parse-media-type: Exported functions
parse-media-type-string: Internal functions

R
render-media-type: Internal functions
render-media-type-params: Internal functions

S
snarf-mime.types: Internal functions
suffix-type: Internal functions

Jump to:   C   D   E   F   M   P   R   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *   +  
A   C   M   P   S   T  
Index Entry  Section

*
*extension-media-types*: Internal special variables
*media-type-extensions*: Internal special variables

+
+storage-for-deflex-var-media-ranges+: Internal constants

A
application/cbor: Internal symbol macros
application/fastinfoset: Internal symbol macros
application/json: Internal symbol macros
application/octet-stream: Internal symbol macros
application/vnd.wap.wbxml: Internal symbol macros
application/x-www-form-urlencoded: Internal symbol macros
application/xml: Internal symbol macros
application/zip: Internal symbol macros

C
Constant, +storage-for-deflex-var-media-ranges+: Internal constants

M
media-ranges: Internal symbol macros
mime.types: Internal symbol macros
multipart/form-data: Internal symbol macros

P
params: Exported structures

S
Slot, params: Exported structures
Slot, subtype: Exported structures
Slot, type: Exported conditions
Slot, type: Exported structures
Special Variable, *extension-media-types*: Internal special variables
Special Variable, *media-type-extensions*: Internal special variables
subtype: Exported structures
suffix-types: Internal symbol macros
Symbol Macro, application/cbor: Internal symbol macros
Symbol Macro, application/fastinfoset: Internal symbol macros
Symbol Macro, application/json: Internal symbol macros
Symbol Macro, application/octet-stream: Internal symbol macros
Symbol Macro, application/vnd.wap.wbxml: Internal symbol macros
Symbol Macro, application/x-www-form-urlencoded: Internal symbol macros
Symbol Macro, application/xml: Internal symbol macros
Symbol Macro, application/zip: Internal symbol macros
Symbol Macro, media-ranges: Internal symbol macros
Symbol Macro, mime.types: Internal symbol macros
Symbol Macro, multipart/form-data: Internal symbol macros
Symbol Macro, suffix-types: Internal symbol macros

T
type: Exported conditions
type: Exported structures

Jump to:   *   +  
A   C   M   P   S   T  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   B   C   D   E   F   I   M   N   P   S   T  
Index Entry  Section

B
bare-extension: Internal types

C
Condition, invalid-media-type: Exported conditions

D
dotted-extension: Internal types

E
extension: Internal types

F
file-designator: Internal types

I
invalid-media-type: Exported conditions

M
media-range: Internal types
media-type: Exported structures
media-type-designator: Internal types
media-types: The media-types system
media-types: The media-types package

N
no-extension: Internal types

P
Package, media-types: The media-types package

S
Structure, media-type: Exported structures
System, media-types: The media-types system

T
Type, bare-extension: Internal types
Type, dotted-extension: Internal types
Type, extension: Internal types
Type, file-designator: Internal types
Type, media-range: Internal types
Type, media-type-designator: Internal types
Type, no-extension: Internal types
Type, type-extensions: Internal types
type-extensions: Internal types

Jump to:   B   C   D   E   F   I   M   N   P   S   T