• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/LWP/H20-Mar-2019-1,7731,638

t/H20-Mar-2019-399307

xt/H20-Mar-2019-377298

ChangesH A D20-Mar-2019804 2519

INSTALLH A D20-Mar-20192.2 KiB7346

LICENSEH A D20-Mar-201917.9 KiB380292

MANIFESTH A D20-Mar-2019512 2726

META.jsonH A D20-Mar-201923.4 KiB737735

META.ymlH A D20-Mar-201915.1 KiB541540

Makefile.PLH A D20-Mar-20191.4 KiB6655

READMEH A D20-Mar-20192.6 KiB7051

cpanfileH A D20-Mar-20191.2 KiB4842

dist.iniH A D20-Mar-20193.3 KiB127104

README

1NAME
2    LWP::MediaTypes - guess media type for a file or a URL
3
4SYNOPSIS
5     use LWP::MediaTypes qw(guess_media_type);
6     $type = guess_media_type("/tmp/foo.gif");
7
8DESCRIPTION
9    This module provides functions for handling media (also known as MIME)
10    types and encodings. The mapping from file extensions to media types is
11    defined by the media.types file. If the ~/.media.types file exists it is
12    used instead. For backwards compatibility we will also look for
13    ~/.mime.types.
14
15    The following functions are exported by default:
16
17    guess_media_type( $filename )
18    guess_media_type( $uri )
19    guess_media_type( $filename_or_uri, $header_to_modify )
20        This function tries to guess media type and encoding for a file or a
21        URI. It returns the content type, which is a string like
22        `"text/html"'. In array context it also returns any content
23        encodings applied (in the order used to encode the file). You can
24        pass a URI object reference, instead of the file name.
25
26        If the type can not be deduced from looking at the file name, then
27        guess_media_type() will let the `-T' Perl operator take a look. If
28        this works (and `-T' returns a TRUE value) then we return
29        *text/plain* as the type, otherwise we return
30        *application/octet-stream* as the type.
31
32        The optional second argument should be a reference to a
33        HTTP::Headers object or any object that implements the $obj->header
34        method in a similar way. When it is present the values of the
35        'Content-Type' and 'Content-Encoding' will be set for this header.
36
37    media_suffix( $type, ... )
38        This function will return all suffixes that can be used to denote
39        the specified media type(s). Wildcard types can be used. In a scalar
40        context it will return the first suffix found. Examples:
41
42          @suffixes = media_suffix('image/*', 'audio/basic');
43          $suffix = media_suffix('text/html');
44
45    The following functions are only exported by explicit request:
46
47    add_type( $type, @exts )
48        Associate a list of file extensions with the given media type.
49        Example:
50
51            add_type("x-world/x-vrml" => qw(wrl vrml));
52
53    add_encoding( $type, @ext )
54        Associate a list of file extensions with an encoding type. Example:
55
56         add_encoding("x-gzip" => "gz");
57
58    read_media_types( @files )
59        Parse media types files and add the type mappings found there.
60        Example:
61
62            read_media_types("conf/mime.types");
63
64COPYRIGHT
65    Copyright 1995-1999 Gisle Aas.
66
67    This library is free software; you can redistribute it and/or modify it
68    under the same terms as Perl itself.
69
70