GX/MIME/Util.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 22 / 22 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« GX/HTTP/Response/Headers.pm ↑ Summary GX/Meta.pm »
1 # ----------------------------------------------------------------------------------------------------------------------
2 # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de>
3 # File: GX/MIME/Util.pm
4 # ----------------------------------------------------------------------------------------------------------------------
5  
6 package GX::MIME::Util;
7  
8 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 # ----------------------------------------------------------------------------------------------------------------------
13 # Data
14 # ----------------------------------------------------------------------------------------------------------------------
15  
16 6 my %FORMAT_TO_MIME_TYPE_MAP = (
17 'bin' => 'application/octet-stream', # n/a
18 'css' => 'text/css', # RFC 2318
19 'csv' => 'text/csv', # RFC 4180
20 'gif' => 'image/gif', # RFC 2045, RFC 2046
21 'html' => 'text/html', # RFC 2854
22 'ico' => 'image/vnd.microsoft.icon', # n/a
23 'jpeg' => 'image/jpeg', # RFC 2045, RFC 2046
24 'js' => 'text/javascript', # RFC 4329
25 'json' => 'application/json', # RFC 4627
26 'pdf' => 'application/pdf', # RFC 3778
27 'png' => 'image/png', # RFC 2083
28 'soap' => 'application/soap+xml', # RFC 3902
29 'svg' => 'image/svg+xml', # SVG Tiny 1.2 Specification Appendix M
30 'tiff' => 'image/tiff', # RFC 3302
31 'txt' => 'text/plain', # RFC 2046
32 'xhtml' => 'application/xhtml+xml', # RFC 3236
33 'xml' => 'text/xml' # RFC 3023
34 );
35  
36  
37 # ----------------------------------------------------------------------------------------------------------------------
38 # Constants
39 # ----------------------------------------------------------------------------------------------------------------------
40  
41 6 ▶use constant REGEX_MIME_TYPE => qr/^[\w\+\-\.]+\/[\w\+\-\.]+$/;
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43  
44 # ----------------------------------------------------------------------------------------------------------------------
45 # Export mechanism
46 # ----------------------------------------------------------------------------------------------------------------------
47  
48 6 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 6 our @EXPORT_OK = qw(
51 format_to_mime_type
52 );
53  
54  
55 # ----------------------------------------------------------------------------------------------------------------------
56 # Public functions
57 # ----------------------------------------------------------------------------------------------------------------------
58  
59 6 ▶sub format_to_mime_type {
Subroutine format_to_mime_type: called CC=1 SCAR=0.0
Pod documented
60  
61 6 return $FORMAT_TO_MIME_TYPE_MAP{$_[0]};
62  
63 }
64  
65  
66 6 1;
67  
68 __END__
« GX/HTTP/Response/Headers.pm ↑ Summary GX/Meta.pm »