1 | // Type definitions for content-disposition 0.5
|
2 | // Project: https://github.com/jshttp/content-disposition
|
3 | // Definitions by: Stefan Reichel <https://github.com/bomret>
|
4 | // Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
5 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
6 |
|
7 | declare namespace contentDisposition {
|
8 | /**
|
9 | * Class for parsed Content-Disposition header for v8 optimization
|
10 | */
|
11 | interface ContentDisposition {
|
12 | /**
|
13 | * The disposition type (always lower case)
|
14 | */
|
15 | type: 'attachment' | 'inline' | string;
|
16 | /**
|
17 | * An object of the parameters in the disposition
|
18 | * (name of parameter always lower case and extended versions replace non-extended versions)
|
19 | */
|
20 | parameters: any;
|
21 | }
|
22 |
|
23 | interface Options {
|
24 | /**
|
25 | * Specifies the disposition type.
|
26 | * This can also be "inline", or any other value (all values except `inline` are treated like attachment,
|
27 | * but can convey additional information if both parties agree to it).
|
28 | * The `type` is normalized to lower-case.
|
29 | * @default 'attachment'
|
30 | */
|
31 | type?: 'attachment' | 'inline' | string;
|
32 | /**
|
33 | * If the filename option is outside ISO-8859-1,
|
34 | * then the file name is actually stored in a supplemental field for clients
|
35 | * that support Unicode file names and a ISO-8859-1 version of the file name is automatically generated
|
36 | * @default true
|
37 | */
|
38 | fallback?: string | boolean;
|
39 | }
|
40 |
|
41 | /**
|
42 | * Parse a Content-Disposition header string
|
43 | */
|
44 | function parse(contentDispositionHeader: string): ContentDisposition;
|
45 | }
|
46 |
|
47 | /**
|
48 | * Create an attachment `Content-Disposition` header value using the given file name, if supplied.
|
49 | * The `filename` is optional and if no file name is desired, but you want to specify options, set `filename` to undefined.
|
50 | */
|
51 | declare function contentDisposition(filename?: string, options?: contentDisposition.Options): string;
|
52 |
|
53 | export = contentDisposition;
|