/[eiffelstudio]/branches/eth/eve/Src/contrib/library/network/protocol/http/tests/http_content_type_set.e
ViewVC logotype

Contents of /branches/eth/eve/Src/contrib/library/network/protocol/http/tests/http_content_type_set.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 92964 - (show annotations)
Fri Sep 20 05:41:23 2013 UTC (6 years ago) by jasonw
File size: 17041 byte(s)
<<Merged from trunk#92963.>>
1 note
2 description : "Objects that ..."
3 author : "$Author$"
4 date : "$Date$"
5 revision : "$Revision$"
6
7 class
8 HTTP_CONTENT_TYPE_SET
9
10 inherit
11 EQA_TEST_SET
12
13 feature -- Content type
14
15
16 test_http_content_types_with_params
17 local
18 do
19 test_content_type_with_params ("text/plain; param1=%"something;foo=bar%"; param2=%"another-thing%"",
20 "text", "plain", <<["param1", "something;foo=bar"], ["param2", "another-thing"]>>
21 )
22 test_content_type ("*", "*", "*")
23 test_content_type_with_params ("* ; q=0.8", "*", "*", <<["q", "0.8"]>>)
24 test_content_type ("*/*", "*", "*")
25 test_content_type ("text/*", "text", "*")
26 end
27
28 test_http_content_type
29 do
30 test_content_type ("application/atom+xml", "application", "atom+xml") -- Atom feeds
31 test_content_type ("application/ecmascript", "application", "ecmascript") -- ECMAScript/JavaScript; Defined in RFC 4329 (equivalent to application/javascript but with stricter processing rules)
32 test_content_type ("application/EDI-X12", "application", "EDI-X12") -- EDI X12 data; Defined in RFC 1767
33 test_content_type ("application/EDIFACT", "application", "EDIFACT") -- EDI EDIFACT data; Defined in RFC 1767
34 test_content_type ("application/json", "application", "json") -- JavaScript Object Notation JSON; Defined in RFC 4627
35 test_content_type ("application/javascript", "application", "javascript") -- ECMAScript/JavaScript; Defined in RFC 4329 (equivalent to application/ecmascript but with looser processing rules) It is not accepted in IE 8 or earlier - text/javascript is accepted but it is defined as obsolete in RFC 4329. The "type" attribute of the <script> tag in HTML5 is optional. In practice, omitting the media type of JavaScript programs is the most interoperable solution, since all browsers have always assumed the correct default even before HTML5.
36 test_content_type ("application/octet-stream", "application", "octet-stream") -- Arbitrary binary data.[10] Generally speaking this type identifies files that are not associated with a specific application. Contrary to past assumptions by software packages such as Apache this is not a type that should be applied to unknown files. In such a case, a server or application should not indicate a content type, as it may be incorrect, but rather, should omit the type in order to allow the recipient to guess the type.[11]
37 test_content_type ("application/ogg", "application", "ogg") -- Ogg, a multimedia bitstream container format; Defined in RFC 5334
38 test_content_type ("application/pdf", "application", "pdf") -- Portable Document Format, PDF has been in use for document exchange on the Internet since 1993; Defined in RFC 3778
39 test_content_type ("application/postscript", "application", "postscript") -- PostScript; Defined in RFC 2046
40 test_content_type ("application/rdf+xml", "application", "rdf+xml") -- Resource Description Framework; Defined by RFC 3870
41 test_content_type ("application/rss+xml", "application", "rss+xml") -- RSS feeds
42 test_content_type ("application/soap+xml", "application", "soap+xml") -- SOAP; Defined by RFC 3902
43 test_content_type ("application/font-woff", "application", "font-woff") -- Web Open Font Format; (candidate recommendation; use application/x-font-woff until standard is official)
44 test_content_type ("application/xhtml+xml", "application", "xhtml+xml") -- XHTML; Defined by RFC 3236
45 test_content_type ("application/xml", "application", "xml") -- XML files; Defined by RFC 3023
46 test_content_type ("application/xml-dtd", "application", "xml-dtd") -- DTD files; Defined by RFC 3023
47 test_content_type ("application/xop+xml", "application", "xop+xml") -- XOP
48 test_content_type ("application/zip", "application", "zip") -- ZIP archive files; Registered[12]
49 test_content_type ("application/gzip", "application", "gzip") -- Gzip, Defined in RFC 6713
50
51 -- Type audio
52 -- For Audio.
53 test_content_type ("audio/basic", "audio", "basic") -- μ-law audio at 8 kHz, 1 channel; Defined in RFC 2046
54 test_content_type ("audio/L24", "audio", "L24") -- 24bit Linear PCM audio at 8–48 kHz, 1-N channels; Defined in RFC 3190
55 test_content_type ("audio/mp4", "audio", "mp4") -- MP4 audio
56 test_content_type ("audio/mpeg", "audio", "mpeg") -- MP3 or other MPEG audio; Defined in RFC 3003
57 test_content_type ("audio/ogg", "audio", "ogg") -- Ogg Vorbis, Speex, Flac and other audio; Defined in RFC 5334
58 test_content_type ("audio/vorbis", "audio", "vorbis") -- Vorbis encoded audio; Defined in RFC 5215
59 test_content_type ("audio/vnd.rn-realaudio", "audio", "vnd.rn-realaudio") -- RealAudio; Documented in RealPlayer Help[13]
60 test_content_type ("audio/vnd.wave", "audio", "vnd.wave") -- WAV audio; Defined in RFC 2361
61 test_content_type ("audio/webm", "audio", "webm") -- WebM open media format
62
63 -- Type image
64 test_content_type ("image/gif", "image", "gif") -- GIF image; Defined in RFC 2045 and RFC 2046
65 test_content_type ("image/jpeg", "image", "jpeg") -- JPEG JFIF image; Defined in RFC 2045 and RFC 2046
66 test_content_type ("image/pjpeg", "image", "pjpeg") -- JPEG JFIF image; Associated with Internet Explorer; Listed in ms775147(v=vs.85) - Progressive JPEG, initiated before global browser support for progressive JPEGs (Microsoft and Firefox).
67 test_content_type ("image/png", "image", "png") -- Portable Network Graphics; Registered,[14] Defined in RFC 2083
68 test_content_type ("image/svg+xml", "image", "svg+xml") -- SVG vector image; Defined in SVG Tiny 1.2 Specification Appendix M
69 test_content_type ("image/tiff", "image", "tiff") -- Tag Image File Format (only for Baseline TIFF); Defined in RFC 3302
70
71 -- Type message
72 test_content_type ("message/http", "message", "http") -- Defined in RFC 2616
73 test_content_type ("message/imdn+xml", "message", "imdn+xml") -- IMDN Instant Message Disposition Notification; Defined in RFC 5438
74 test_content_type ("message/partial", "message", "partial") -- Email; Defined in RFC 2045 and RFC 2046
75 test_content_type ("message/rfc822", "message", "rfc822") -- Email; EML files, MIME files, MHT files, MHTML files; Defined in RFC 2045 and RFC 2046
76
77 -- Type model
78 -- For 3D models.
79 test_content_type ("model/example", "model", "example") -- Defined in RFC 4735
80 test_content_type ("model/iges", "model", "iges") -- IGS files, IGES files; Defined in RFC 2077
81 test_content_type ("model/mesh", "model", "mesh") -- MSH files, MESH files; Defined in RFC 2077, SILO files
82 test_content_type ("model/vrml", "model", "vrml") -- WRL files, VRML files; Defined in RFC 2077
83 test_content_type ("model/x3d+binary", "model", "x3d+binary") -- X3D ISO standard for representing 3D computer graphics, X3DB binary files
84 test_content_type ("model/x3d+vrml", "model", "x3d+vrml") -- X3D ISO standard for representing 3D computer graphics, X3DV VRML files
85 test_content_type ("model/x3d+xml", "model", "x3d+xml") -- X3D ISO standard for representing 3D computer graphics, X3D XML files
86
87 -- Type multipart
88 -- For archives and other objects made of more than one part.
89 test_content_type ("multipart/mixed", "multipart", "mixed") -- MIME Email; Defined in RFC 2045 and RFC 2046
90 test_content_type ("multipart/alternative", "multipart", "alternative") -- MIME Email; Defined in RFC 2045 and RFC 2046
91 test_content_type ("multipart/related", "multipart", "related") -- MIME Email; Defined in RFC 2387 and used by MHTML (HTML mail)
92 test_content_type ("multipart/form-data", "multipart", "form-data") -- MIME Webform; Defined in RFC 2388
93 test_content_type ("multipart/signed", "multipart", "signed") -- Defined in RFC 1847
94 test_content_type ("multipart/encrypted", "multipart", "encrypted") -- Defined in RFC 1847
95
96 -- Type text
97 -- For human-readable text and source code.
98 test_content_type ("text/cmd", "text", "cmd") -- commands; subtype resident in Gecko browsers like Firefox 3.5
99 test_content_type ("text/css", "text", "css") -- Cascading Style Sheets; Defined in RFC 2318
100 test_content_type ("text/csv", "text", "csv") -- Comma-separated values; Defined in RFC 4180
101 test_content_type ("text/html", "text", "html") -- HTML; Defined in RFC 2854
102 test_content_type ("text/javascript", "text", "javascript") -- (Obsolete) JavaScript; Defined in and obsoleted by RFC 4329 in order to discourage its usage in favor of application/javascript. However, text/javascript is allowed in HTML 4 and 5 and, unlike application/javascript, has cross-browser support. The "type" attribute of the <script> tag in HTML5 is optional and there is no need to use it at all since all browsers have always assumed the correct default (even in HTML 4 where it was required by the specification).
103 test_content_type ("text/plain", "text", "plain") -- Textual data; Defined in RFC 2046 and RFC 3676
104 test_content_type ("text/vcard", "text", "vcard") -- vCard (contact information); Defined in RFC 6350
105 test_content_type ("text/xml", "text", "xml") -- Extensible Markup Language; Defined in RFC 3023
106
107 -- Type video
108 -- For video.
109 test_content_type ("video/mpeg", "video", "mpeg") -- MPEG-1 video with multiplexed audio; Defined in RFC 2045 and RFC 2046
110 test_content_type ("video/mp4", "video", "mp4") -- MP4 video; Defined in RFC 4337
111 test_content_type ("video/ogg", "video", "ogg") -- Ogg Theora or other video (with audio); Defined in RFC 5334
112 test_content_type ("video/quicktime", "video", "quicktime") -- QuickTime video; Registered[15]
113 test_content_type ("video/webm", "video", "webm") -- WebM Matroska-based open media format
114 test_content_type ("video/x-matroska", "video", "x-matroska") -- Matroska open media format
115 test_content_type ("video/x-ms-wmv", "video", "x-ms-wmv") -- Windows Media Video; Documented in Microsoft KB 288102
116 test_content_type ("video/x-flv", "video", "x-flv") -- Flash video (FLV files)
117
118 -- List of common media subtype prefixes
119 -- Prefix vnd
120 -- For vendor-specific files.
121 test_content_type ("application/vnd.oasis.opendocument.text", "application", "vnd.oasis.opendocument.text") -- OpenDocument Text; Registered[16]
122 test_content_type ("application/vnd.oasis.opendocument.spreadsheet", "application", "vnd.oasis.opendocument.spreadsheet") -- OpenDocument Spreadsheet; Registered[17]
123 test_content_type ("application/vnd.oasis.opendocument.presentation", "application", "vnd.oasis.opendocument.presentation") -- OpenDocument Presentation; Registered[18]
124 test_content_type ("application/vnd.oasis.opendocument.graphics", "application", "vnd.oasis.opendocument.graphics") -- OpenDocument Graphics; Registered[19]
125 test_content_type ("application/vnd.ms-excel", "application", "vnd.ms-excel") -- Microsoft Excel files
126 test_content_type ("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application", "vnd.openxmlformats-officedocument.spreadsheetml.sheet") -- Microsoft Excel 2007 files
127 test_content_type ("application/vnd.ms-powerpoint", "application", "vnd.ms-powerpoint") -- Microsoft Powerpoint files
128 test_content_type ("application/vnd.openxmlformats-officedocument.presentationml.presentation", "application", "vnd.openxmlformats-officedocument.presentationml.presentation") -- Microsoft Powerpoint 2007 files
129 test_content_type ("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application", "vnd.openxmlformats-officedocument.wordprocessingml.document") -- Microsoft Word 2007 files
130 test_content_type ("application/vnd.mozilla.xul+xml", "application", "vnd.mozilla.xul+xml") -- Mozilla XUL files
131 test_content_type ("application/vnd.google-earth.kml+xml", "application", "vnd.google-earth.kml+xml") -- KML files (e.g. for Google Earth)[20]
132 test_content_type ("application/vnd.google-earth.kmz", "application", "vnd.google-earth.kmz") -- KMZ files (e.g. for Google Earth)[21]
133 test_content_type ("application/vnd.dart", "application", "vnd.dart") -- Dart files [22]
134 test_content_type ("application/vnd.android.package-archive", "application", "vnd.android.package-archive") -- For download apk files.
135 test_content_type ("application/vnd.ms-xpsdocument", "application", "vnd.ms-xpsdocument") -- XPS document[23]
136
137 -- Prefix x
138 -- For non-standard files. Deprecated by RFC 6648.[2]
139 test_content_type ("application/x-7z-compressed", "application", "x-7z-compressed") -- 7-Zip compression format.
140 test_content_type ("application/x-deb", "application", "x-deb") -- deb (file format), a software package format used by the Debian project
141 test_content_type ("application/x-dvi", "application", "x-dvi") -- device-independent document in DVI format
142 test_content_type ("application/x-font-ttf", "application", "x-font-ttf") -- TrueType Font No registered MIME type, but this is the most commonly used
143 test_content_type ("application/x-javascript", "application", "x-javascript") --
144 test_content_type ("application/x-latex", "application", "x-latex") -- LaTeX files
145 test_content_type ("application/x-mpegURL", "application", "x-mpegURL") -- .m3u8 variant playlist
146 test_content_type ("application/x-rar-compressed", "application", "x-rar-compressed") -- RAR archive files
147 test_content_type ("application/x-shockwave-flash", "application", "x-shockwave-flash") -- Adobe Flash files for example with the extension .swf
148 test_content_type ("application/x-stuffit", "application", "x-stuffit") -- StuffIt archive files
149 test_content_type ("application/x-tar", "application", "x-tar") -- Tarball files
150 test_content_type ("application/x-www-form-urlencoded", "application", "x-www-form-urlencoded") -- Form Encoded Data; Documented in HTML 4.01 Specification, Section 17.13.4.1
151 test_content_type ("application/x-xpinstall", "application", "x-xpinstall") -- Add-ons to Mozilla applications (Firefox, Thunderbird, SeaMonkey, and the discontinued Sunbird)
152 test_content_type ("audio/x-aac", "audio", "x-aac") -- .aac audio files
153 test_content_type ("audio/x-caf", "audio", "x-caf") -- Apple's CAF audio files
154 test_content_type ("image/x-xcf", "image", "x-xcf") -- GIMP image file
155 test_content_type ("text/x-gwt-rpc", "text", "x-gwt-rpc") -- GoogleWebToolkit data
156 test_content_type ("text/x-jquery-tmpl", "text", "x-jquery-tmpl") -- jQuery template data
157 test_content_type ("text/x-markdown", "text", "x-markdown") -- Markdown formatted text
158 test_content_type ("application/x-pkcs12", "application", "x-pkcs12") -- a variant of PKCS standard files
159 end
160
161 test_http_content_type_multipart
162 do
163 test_content_type_with_params ("multipart/mixed; boundary=%"simple boundary%"", "multipart", "mixed", <<["boundary", "simple boundary"]>>)
164 test_content_type_with_params ("multipart/alternative; boundary=boundary42", "multipart", "alternative", <<["boundary", "boundary42"]>>)
165 test_content_type_with_params ("multipart/mixed;%N boundary=%"---- main boundary ----%"", "multipart", "mixed", <<["boundary", "---- main boundary ----"]>>)
166 test_content_type_with_params ("multipart/digest;%N boundary=%"---- next message ----%"", "multipart", "digest", <<["boundary", "---- next message ----"]>>)
167
168 end
169
170 test_http_content_type_partial
171 do
172 -- Content-Type: Message/Partial; number=2; total=3;
173 -- id="oc=jpbe0M2Yt4s@thumper.bellcore.com"
174 -- Content-Type: Message/Partial;
175 -- id="oc=jpbe0M2Yt4s@thumper.bellcore.com";
176 -- number=2
177 -- Content-Type: Message/Partial; number=3; total=3;
178 -- id="oc=jpbe0M2Yt4s@thumper.bellcore.com"
179
180 test_content_type_with_params ("Message/Partial; number=2; total=3;%N id=%"oc=jpbe0M2Yt4s@thumper.bellcore.com%"", "Message", "Partial", <<["number", "2"], ["total", "3"], ["id", "oc=jpbe0M2Yt4s@thumper.bellcore.com"]>>)
181 test_content_type_with_params ("Message/Partial; id=%"oc=jpbe0M2Yt4s@thumper.bellcore.com%";%N number=2", "Message", "Partial", <<["id", "oc=jpbe0M2Yt4s@thumper.bellcore.com"], ["number", "2"] >>)
182 test_content_type_with_params ("Message/Partial; number=3; total=3; id=%"oc=jpbe0M2Yt4s@thumper.bellcore.com%";%N", "Message", "Partial", <<["number", "3"], ["total", "3"], ["id", "oc=jpbe0M2Yt4s@thumper.bellcore.com"]>>)
183
184 assert ("Partial is not implemented", True)
185 end
186 feature {NONE} -- Implementation
187
188 test_content_type (a_string: READABLE_STRING_8; a_type, a_subtype: READABLE_STRING_8)
189 local
190 ct1,ct2: HTTP_CONTENT_TYPE
191 do
192 create ct1.make_from_string (a_string)
193 create ct2.make (a_type, a_subtype)
194 assert (a_string, ct1.same_as (ct2))
195 end
196
197 test_content_type_with_params (a_string: READABLE_STRING_8; a_type, a_subtype: READABLE_STRING_8; params: detachable ARRAY [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
198 local
199 ct1,ct2: HTTP_CONTENT_TYPE
200 do
201 create ct1.make_from_string (a_string)
202 create ct2.make (a_type, a_subtype)
203 if params /= Void then
204 across
205 params as c
206 loop
207 ct2.add_parameter (c.item.name, c.item.value)
208 end
209 end
210 assert (a_string, ct1.same_as (ct2))
211 end
212
213 end
214

Properties

Name Value
svn:eol-style native
svn:keywords Author Date ID Revision

  ViewVC Help
Powered by ViewVC 1.1.23