WebServer.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. using System;
  2. using System.IO;
  3. using System.Net;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Collections.Generic;
  7. namespace BabylonHosting
  8. {
  9. public static class WebServer
  10. {
  11. public static string Root { get; private set; }
  12. public static bool IsSupported { get; private set; }
  13. public static HttpListener HostListener { get; private set; }
  14. static WebServer()
  15. {
  16. Root = String.Empty;
  17. IsSupported = false;
  18. HostListener = null;
  19. SetupFileTypeMappings();
  20. }
  21. public static bool Activate(string prefix, string root, int port)
  22. {
  23. bool started = false;
  24. WebServer.Root = root;
  25. if (WebServer.HostListener == null)
  26. {
  27. try
  28. {
  29. WebServer.HostListener = new HttpListener();
  30. if (!HttpListener.IsSupported)
  31. {
  32. IsSupported = false;
  33. return false;
  34. }
  35. string protocol = prefix;
  36. if (String.IsNullOrEmpty(protocol))
  37. {
  38. protocol = "http://*:";
  39. }
  40. if (protocol.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
  41. {
  42. // TODO: Enable Basic SSL Support
  43. }
  44. WebServer.HostListener.Prefixes.Add(protocol + port.ToString() + "/");
  45. WebServer.HostListener.Start();
  46. ThreadPool.QueueUserWorkItem(Listen);
  47. started = true;
  48. IsSupported = true;
  49. }
  50. catch
  51. {
  52. WebServer.HostListener = null;
  53. IsSupported = false;
  54. }
  55. }
  56. return started;
  57. }
  58. static void Listen(object state)
  59. {
  60. try
  61. {
  62. while (WebServer.HostListener.IsListening)
  63. {
  64. var context = WebServer.HostListener.GetContext();
  65. var request = context.Request;
  66. var url = request.Url;
  67. if (String.IsNullOrEmpty(WebServer.Root)) WebServer.Root = "/";
  68. try
  69. {
  70. string path = String.Empty;
  71. context.Response.AddHeader("Cache-Control", "no-cache");
  72. if (string.IsNullOrEmpty(url.LocalPath) || url.LocalPath == "/")
  73. {
  74. path = Path.Combine(WebServer.Root, "index.html");
  75. if (!File.Exists(path))
  76. {
  77. path = Path.Combine(WebServer.Root, "index.htm");
  78. if (!File.Exists(path))
  79. {
  80. path = Path.Combine(WebServer.Root, "default.html");
  81. if (!File.Exists(path))
  82. {
  83. path = Path.Combine(WebServer.Root, "default.htm");
  84. if (!File.Exists(path))
  85. {
  86. path = Path.Combine(WebServer.Root, "index.html");
  87. }
  88. }
  89. }
  90. }
  91. }
  92. else
  93. {
  94. path = Path.Combine(WebServer.Root, UnityEngine.WWW.UnEscapeURL(url.PathAndQuery.Substring(1)));
  95. }
  96. if (!String.IsNullOrEmpty(path))
  97. {
  98. var questionMarkIndex = path.IndexOf("?");
  99. if (questionMarkIndex != -1)
  100. {
  101. path = path.Substring(0, questionMarkIndex);
  102. }
  103. var hashIndex = path.IndexOf("#");
  104. if (hashIndex != -1)
  105. {
  106. path = path.Substring(0, hashIndex);
  107. }
  108. if (File.Exists(path))
  109. {
  110. WriteResponse(context, new FileInfo(path));
  111. }
  112. else
  113. {
  114. context.Response.StatusCode = 404;
  115. context.Response.StatusDescription = "File Not Found";
  116. context.Response.Close();
  117. continue;
  118. }
  119. }
  120. else
  121. {
  122. throw new Exception("Failed to format valid request path.");
  123. }
  124. }
  125. catch (Exception ex)
  126. {
  127. context.Response.StatusCode = 500;
  128. context.Response.StatusDescription = ex.Message;
  129. context.Response.Close();
  130. UnityEngine.Debug.LogException(ex);
  131. continue;
  132. }
  133. }
  134. }
  135. catch
  136. {
  137. // Note: Thread Abort Excpetions Caught Here
  138. }
  139. }
  140. static void WriteResponse(HttpListenerContext context, string s)
  141. {
  142. WriteResponse(context.Response, s);
  143. }
  144. static void WriteResponse(HttpListenerContext context, byte[] buffer)
  145. {
  146. WriteResponse(context.Response, buffer);
  147. }
  148. static void WriteResponse(HttpListenerContext context, FileInfo info)
  149. {
  150. WriteResponse(context.Response, info);
  151. }
  152. static void WriteResponse(HttpListenerContext context, Stream stream)
  153. {
  154. WriteResponse(context.Response, stream);
  155. }
  156. static void WriteResponse(HttpListenerResponse response, string s)
  157. {
  158. byte[] buffer = Encoding.UTF8.GetBytes(s);
  159. WriteResponse(response, buffer);
  160. }
  161. static void WriteResponse(HttpListenerResponse response, byte[] buffer)
  162. {
  163. response.ContentLength64 = buffer.Length;
  164. Stream output = response.OutputStream;
  165. output.Write(buffer, 0, buffer.Length);
  166. output.Close();
  167. }
  168. static void WriteResponse(HttpListenerResponse response, FileInfo info)
  169. {
  170. Stream file = info.OpenRead();
  171. response.ContentType = GetMimeType(info);
  172. WriteResponse(response, file);
  173. file.Close();
  174. }
  175. static void WriteResponse(HttpListenerResponse response, Stream stream)
  176. {
  177. response.ContentLength64 = stream.Length;
  178. Stream output = response.OutputStream;
  179. stream.CopyTo(response.OutputStream, true, (1024 * 32));
  180. output.Close();
  181. }
  182. static string GetMimeType(string filename)
  183. {
  184. return GetMimeType(new FileInfo(filename));
  185. }
  186. static string GetMimeType(FileInfo info)
  187. {
  188. string content_type = "application/octet-stream";
  189. if (Mappings != null)
  190. {
  191. string extension = info.Extension;
  192. if (!String.IsNullOrEmpty(extension))
  193. {
  194. Mappings.TryGetValue(extension, out content_type);
  195. }
  196. }
  197. return (!String.IsNullOrEmpty(content_type)) ? content_type : "application/octet-stream";
  198. }
  199. public static void CopyTo(this Stream source, Stream destination, bool finalFlush = false, int bufferSize = 4096, long maxCount = -1)
  200. {
  201. byte[] buffer = new byte[bufferSize];
  202. long totalBytesWritten = 0;
  203. while (true)
  204. {
  205. int count = buffer.Length;
  206. if (maxCount > 0)
  207. {
  208. if (totalBytesWritten > maxCount - count)
  209. {
  210. count = (int)(maxCount - totalBytesWritten);
  211. if (count <= 0)
  212. {
  213. break;
  214. }
  215. }
  216. }
  217. int read = source.Read(buffer, 0, count);
  218. if (read <= 0)
  219. {
  220. break;
  221. }
  222. destination.Write(buffer, 0, read);
  223. totalBytesWritten += read;
  224. }
  225. if (finalFlush)
  226. {
  227. try { destination.Flush(); } catch { }
  228. }
  229. }
  230. static IDictionary<string, string> Mappings = null;
  231. static void SetupFileTypeMappings()
  232. {
  233. #region Default Content Mappings
  234. Mappings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) {
  235. { ".323", "text/h323" },
  236. { ".3g2", "video/3gpp2" },
  237. { ".3gp2", "video/3gpp2" },
  238. { ".3gp", "video/3gpp" },
  239. { ".3gpp", "video/3gpp" },
  240. { ".aac", "audio/aac" },
  241. { ".aaf", "application/octet-stream" },
  242. { ".aca", "application/octet-stream" },
  243. { ".accdb", "application/msaccess" },
  244. { ".accde", "application/msaccess" },
  245. { ".accdt", "application/msaccess" },
  246. { ".acx", "application/internet-property-stream" },
  247. { ".adt", "audio/vnd.dlna.adts" },
  248. { ".adts", "audio/vnd.dlna.adts" },
  249. { ".afm", "application/octet-stream" },
  250. { ".ai", "application/postscript" },
  251. { ".aif", "audio/x-aiff" },
  252. { ".aifc", "audio/aiff" },
  253. { ".aiff", "audio/aiff" },
  254. { ".application", "application/x-ms-application" },
  255. { ".art", "image/x-jg" },
  256. { ".asd", "application/octet-stream" },
  257. { ".asf", "video/x-ms-asf" },
  258. { ".asi", "application/octet-stream" },
  259. { ".asm", "text/plain" },
  260. { ".asr", "video/x-ms-asf" },
  261. { ".asx", "video/x-ms-asf" },
  262. { ".atom", "application/atom+xml" },
  263. { ".au", "audio/basic" },
  264. { ".avi", "video/x-msvideo" },
  265. { ".axs", "application/olescript" },
  266. { ".bas", "text/plain" },
  267. { ".bcpio", "application/x-bcpio" },
  268. { ".bin", "application/octet-stream" },
  269. { ".bmp", "image/bmp" },
  270. { ".c", "text/plain" },
  271. { ".cab", "application/vnd.ms-cab-compressed" },
  272. { ".calx", "application/vnd.ms-office.calx" },
  273. { ".cat", "application/vnd.ms-pki.seccat" },
  274. { ".cdf", "application/x-cdf" },
  275. { ".chm", "application/octet-stream" },
  276. { ".class", "application/x-java-applet" },
  277. { ".clp", "application/x-msclip" },
  278. { ".cmx", "image/x-cmx" },
  279. { ".cnf", "text/plain" },
  280. { ".cod", "image/cis-cod" },
  281. { ".cpio", "application/x-cpio" },
  282. { ".cpp", "text/plain" },
  283. { ".crd", "application/x-mscardfile" },
  284. { ".crl", "application/pkix-crl" },
  285. { ".crt", "application/x-x509-ca-cert" },
  286. { ".csh", "application/x-csh" },
  287. { ".css", "text/css" },
  288. { ".csv", "application/octet-stream" },
  289. { ".cur", "application/octet-stream" },
  290. { ".dcr", "application/x-director" },
  291. { ".deploy", "application/octet-stream" },
  292. { ".der", "application/x-x509-ca-cert" },
  293. { ".dib", "image/bmp" },
  294. { ".dir", "application/x-director" },
  295. { ".disco", "text/xml" },
  296. { ".dlm", "text/dlm" },
  297. { ".doc", "application/msword" },
  298. { ".docm", "application/vnd.ms-word.document.macroEnabled.12" },
  299. { ".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document" },
  300. { ".dot", "application/msword" },
  301. { ".dotm", "application/vnd.ms-word.template.macroEnabled.12" },
  302. { ".dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template" },
  303. { ".dsp", "application/octet-stream" },
  304. { ".dtd", "text/xml" },
  305. { ".dvi", "application/x-dvi" },
  306. { ".dvr-ms", "video/x-ms-dvr" },
  307. { ".dwf", "drawing/x-dwf" },
  308. { ".dwp", "application/octet-stream" },
  309. { ".dxr", "application/x-director" },
  310. { ".eml", "message/rfc822" },
  311. { ".emz", "application/octet-stream" },
  312. { ".eot", "application/vnd.ms-fontobject" },
  313. { ".eps", "application/postscript" },
  314. { ".etx", "text/x-setext" },
  315. { ".evy", "application/envoy" },
  316. { ".fdf", "application/vnd.fdf" },
  317. { ".fif", "application/fractals" },
  318. { ".fla", "application/octet-stream" },
  319. { ".flr", "x-world/x-vrml" },
  320. { ".flv", "video/x-flv" },
  321. { ".gif", "image/gif" },
  322. { ".gtar", "application/x-gtar" },
  323. { ".gz", "application/x-gzip" },
  324. { ".h", "text/plain" },
  325. { ".hdf", "application/x-hdf" },
  326. { ".hdml", "text/x-hdml" },
  327. { ".hhc", "application/x-oleobject" },
  328. { ".hhk", "application/octet-stream" },
  329. { ".hhp", "application/octet-stream" },
  330. { ".hlp", "application/winhlp" },
  331. { ".hqx", "application/mac-binhex40" },
  332. { ".hta", "application/hta" },
  333. { ".htc", "text/x-component" },
  334. { ".htm", "text/html" },
  335. { ".html", "text/html" },
  336. { ".htt", "text/webviewhtml" },
  337. { ".hxt", "text/html" },
  338. { ".ical", "text/calendar" },
  339. { ".icalendar", "text/calendar" },
  340. { ".ico", "image/x-icon" },
  341. { ".ics", "text/calendar" },
  342. { ".ief", "image/ief" },
  343. { ".ifb", "text/calendar" },
  344. { ".iii", "application/x-iphone" },
  345. { ".inf", "application/octet-stream" },
  346. { ".ins", "application/x-internet-signup" },
  347. { ".isp", "application/x-internet-signup" },
  348. { ".IVF", "video/x-ivf" },
  349. { ".jar", "application/java-archive" },
  350. { ".java", "application/octet-stream" },
  351. { ".jck", "application/liquidmotion" },
  352. { ".jcz", "application/liquidmotion" },
  353. { ".jfif", "image/pjpeg" },
  354. { ".jpb", "application/octet-stream" },
  355. { ".jpe", "image/jpeg" },
  356. { ".jpeg", "image/jpeg" },
  357. { ".jpg", "image/jpeg" },
  358. { ".js", "application/javascript" },
  359. { ".bjs", "application/javascript" },
  360. { ".javascript", "application/javascript" },
  361. { ".latex", "application/x-latex" },
  362. { ".lit", "application/x-ms-reader" },
  363. { ".lpk", "application/octet-stream" },
  364. { ".lsf", "video/x-la-asf" },
  365. { ".lsx", "video/x-la-asf" },
  366. { ".lzh", "application/octet-stream" },
  367. { ".m13", "application/x-msmediaview" },
  368. { ".m14", "application/x-msmediaview" },
  369. { ".m1v", "video/mpeg" },
  370. { ".m2ts", "video/vnd.dlna.mpeg-tts" },
  371. { ".m3u", "audio/x-mpegurl" },
  372. { ".m4a", "audio/mp4" },
  373. { ".m4v", "video/mp4" },
  374. { ".man", "application/x-troff-man" },
  375. { ".manifest", "application/x-ms-manifest" },
  376. { ".map", "text/plain" },
  377. { ".mdb", "application/x-msaccess" },
  378. { ".mdp", "application/octet-stream" },
  379. { ".me", "application/x-troff-me" },
  380. { ".mht", "message/rfc822" },
  381. { ".mhtml", "message/rfc822" },
  382. { ".mid", "audio/mid" },
  383. { ".midi", "audio/mid" },
  384. { ".mix", "application/octet-stream" },
  385. { ".mmf", "application/x-smaf" },
  386. { ".mno", "text/xml" },
  387. { ".mny", "application/x-msmoney" },
  388. { ".mov", "video/quicktime" },
  389. { ".movie", "video/x-sgi-movie" },
  390. { ".mp2", "video/mpeg" },
  391. { ".mp3", "audio/mpeg" },
  392. { ".mp4", "video/mp4" },
  393. { ".mp4v", "video/mp4" },
  394. { ".mpa", "video/mpeg" },
  395. { ".mpe", "video/mpeg" },
  396. { ".mpeg", "video/mpeg" },
  397. { ".mpg", "video/mpeg" },
  398. { ".mpp", "application/vnd.ms-project" },
  399. { ".mpv2", "video/mpeg" },
  400. { ".ms", "application/x-troff-ms" },
  401. { ".msi", "application/octet-stream" },
  402. { ".mso", "application/octet-stream" },
  403. { ".mvb", "application/x-msmediaview" },
  404. { ".mvc", "application/x-miva-compiled" },
  405. { ".nc", "application/x-netcdf" },
  406. { ".nsc", "video/x-ms-asf" },
  407. { ".nws", "message/rfc822" },
  408. { ".ocx", "application/octet-stream" },
  409. { ".oda", "application/oda" },
  410. { ".odc", "text/x-ms-odc" },
  411. { ".ods", "application/oleobject" },
  412. { ".oga", "audio/ogg" },
  413. { ".ogg", "video/ogg" },
  414. { ".ogv", "video/ogg" },
  415. { ".ogx", "application/ogg" },
  416. { ".one", "application/onenote" },
  417. { ".onea", "application/onenote" },
  418. { ".onetoc", "application/onenote" },
  419. { ".onetoc2", "application/onenote" },
  420. { ".onetmp", "application/onenote" },
  421. { ".onepkg", "application/onenote" },
  422. { ".osdx", "application/opensearchdescription+xml" },
  423. { ".otf", "font/otf" },
  424. { ".p10", "application/pkcs10" },
  425. { ".p12", "application/x-pkcs12" },
  426. { ".p7b", "application/x-pkcs7-certificates" },
  427. { ".p7c", "application/pkcs7-mime" },
  428. { ".p7m", "application/pkcs7-mime" },
  429. { ".p7r", "application/x-pkcs7-certreqresp" },
  430. { ".p7s", "application/pkcs7-signature" },
  431. { ".pbm", "image/x-portable-bitmap" },
  432. { ".pcx", "application/octet-stream" },
  433. { ".pcz", "application/octet-stream" },
  434. { ".pdf", "application/pdf" },
  435. { ".pfb", "application/octet-stream" },
  436. { ".pfm", "application/octet-stream" },
  437. { ".pfx", "application/x-pkcs12" },
  438. { ".pgm", "image/x-portable-graymap" },
  439. { ".pko", "application/vnd.ms-pki.pko" },
  440. { ".pma", "application/x-perfmon" },
  441. { ".pmc", "application/x-perfmon" },
  442. { ".pml", "application/x-perfmon" },
  443. { ".pmr", "application/x-perfmon" },
  444. { ".pmw", "application/x-perfmon" },
  445. { ".png", "image/png" },
  446. { ".pnm", "image/x-portable-anymap" },
  447. { ".pnz", "image/png" },
  448. { ".pot", "application/vnd.ms-powerpoint" },
  449. { ".potm", "application/vnd.ms-powerpoint.template.macroEnabled.12" },
  450. { ".potx", "application/vnd.openxmlformats-officedocument.presentationml.template" },
  451. { ".ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12" },
  452. { ".ppm", "image/x-portable-pixmap" },
  453. { ".pps", "application/vnd.ms-powerpoint" },
  454. { ".ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12" },
  455. { ".ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow" },
  456. { ".ppt", "application/vnd.ms-powerpoint" },
  457. { ".pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12" },
  458. { ".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation" },
  459. { ".prf", "application/pics-rules" },
  460. { ".prm", "application/octet-stream" },
  461. { ".prx", "application/octet-stream" },
  462. { ".ps", "application/postscript" },
  463. { ".psd", "application/octet-stream" },
  464. { ".psm", "application/octet-stream" },
  465. { ".psp", "application/octet-stream" },
  466. { ".pub", "application/x-mspublisher" },
  467. { ".qt", "video/quicktime" },
  468. { ".qtl", "application/x-quicktimeplayer" },
  469. { ".qxd", "application/octet-stream" },
  470. { ".ra", "audio/x-pn-realaudio" },
  471. { ".ram", "audio/x-pn-realaudio" },
  472. { ".rar", "application/octet-stream" },
  473. { ".ras", "image/x-cmu-raster" },
  474. { ".rf", "image/vnd.rn-realflash" },
  475. { ".rgb", "image/x-rgb" },
  476. { ".rm", "application/vnd.rn-realmedia" },
  477. { ".rmi", "audio/mid" },
  478. { ".roff", "application/x-troff" },
  479. { ".rpm", "audio/x-pn-realaudio-plugin" },
  480. { ".rtf", "application/rtf" },
  481. { ".rtx", "text/richtext" },
  482. { ".scd", "application/x-msschedule" },
  483. { ".sct", "text/scriptlet" },
  484. { ".sea", "application/octet-stream" },
  485. { ".setpay", "application/set-payment-initiation" },
  486. { ".setreg", "application/set-registration-initiation" },
  487. { ".sgml", "text/sgml" },
  488. { ".sh", "application/x-sh" },
  489. { ".shar", "application/x-shar" },
  490. { ".sit", "application/x-stuffit" },
  491. { ".sldm", "application/vnd.ms-powerpoint.slide.macroEnabled.12" },
  492. { ".sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide" },
  493. { ".smd", "audio/x-smd" },
  494. { ".smi", "application/octet-stream" },
  495. { ".smx", "audio/x-smd" },
  496. { ".smz", "audio/x-smd" },
  497. { ".snd", "audio/basic" },
  498. { ".snp", "application/octet-stream" },
  499. { ".spc", "application/x-pkcs7-certificates" },
  500. { ".spl", "application/futuresplash" },
  501. { ".spx", "audio/ogg" },
  502. { ".src", "application/x-wais-source" },
  503. { ".ssm", "application/streamingmedia" },
  504. { ".sst", "application/vnd.ms-pki.certstore" },
  505. { ".stl", "application/vnd.ms-pki.stl" },
  506. { ".sv4cpio", "application/x-sv4cpio" },
  507. { ".sv4crc", "application/x-sv4crc" },
  508. { ".svg", "image/svg+xml" },
  509. { ".svgz", "image/svg+xml" },
  510. { ".swf", "application/x-shockwave-flash" },
  511. { ".t", "application/x-troff" },
  512. { ".tar", "application/x-tar" },
  513. { ".tcl", "application/x-tcl" },
  514. { ".tex", "application/x-tex" },
  515. { ".texi", "application/x-texinfo" },
  516. { ".texinfo", "application/x-texinfo" },
  517. { ".tgz", "application/x-compressed" },
  518. { ".thmx", "application/vnd.ms-officetheme" },
  519. { ".thn", "application/octet-stream" },
  520. { ".tif", "image/tiff" },
  521. { ".tiff", "image/tiff" },
  522. { ".toc", "application/octet-stream" },
  523. { ".tr", "application/x-troff" },
  524. { ".trm", "application/x-msterminal" },
  525. { ".ts", "video/vnd.dlna.mpeg-tts" },
  526. { ".tsv", "text/tab-separated-values" },
  527. { ".ttf", "application/octet-stream" },
  528. { ".tts", "video/vnd.dlna.mpeg-tts" },
  529. { ".txt", "text/plain" },
  530. { ".u32", "application/octet-stream" },
  531. { ".uls", "text/iuls" },
  532. { ".ustar", "application/x-ustar" },
  533. { ".vbs", "text/vbscript" },
  534. { ".vcf", "text/x-vcard" },
  535. { ".vcs", "text/plain" },
  536. { ".vdx", "application/vnd.ms-visio.viewer" },
  537. { ".vml", "text/xml" },
  538. { ".vsd", "application/vnd.visio" },
  539. { ".vss", "application/vnd.visio" },
  540. { ".vst", "application/vnd.visio" },
  541. { ".vsto", "application/x-ms-vsto" },
  542. { ".vsw", "application/vnd.visio" },
  543. { ".vsx", "application/vnd.visio" },
  544. { ".vtx", "application/vnd.visio" },
  545. { ".wav", "audio/wav" },
  546. { ".wax", "audio/x-ms-wax" },
  547. { ".wbmp", "image/vnd.wap.wbmp" },
  548. { ".wcm", "application/vnd.ms-works" },
  549. { ".wdb", "application/vnd.ms-works" },
  550. { ".webm", "video/webm" },
  551. { ".wks", "application/vnd.ms-works" },
  552. { ".wm", "video/x-ms-wm" },
  553. { ".wma", "audio/x-ms-wma" },
  554. { ".wmd", "application/x-ms-wmd" },
  555. { ".wmf", "application/x-msmetafile" },
  556. { ".wml", "text/vnd.wap.wml" },
  557. { ".wmlc", "application/vnd.wap.wmlc" },
  558. { ".wmls", "text/vnd.wap.wmlscript" },
  559. { ".wmlsc", "application/vnd.wap.wmlscriptc" },
  560. { ".wmp", "video/x-ms-wmp" },
  561. { ".wmv", "video/x-ms-wmv" },
  562. { ".wmx", "video/x-ms-wmx" },
  563. { ".wmz", "application/x-ms-wmz" },
  564. { ".woff", "application/font-woff" },
  565. { ".wps", "application/vnd.ms-works" },
  566. { ".wri", "application/x-mswrite" },
  567. { ".wrl", "x-world/x-vrml" },
  568. { ".wrz", "x-world/x-vrml" },
  569. { ".wsdl", "text/xml" },
  570. { ".wtv", "video/x-ms-wtv" },
  571. { ".wvx", "video/x-ms-wvx" },
  572. { ".x", "application/directx" },
  573. { ".xaf", "x-world/x-vrml" },
  574. { ".xaml", "application/xaml+xml" },
  575. { ".xap", "application/x-silverlight-app" },
  576. { ".xbap", "application/x-ms-xbap" },
  577. { ".xbm", "image/x-xbitmap" },
  578. { ".xdr", "text/plain" },
  579. { ".xht", "application/xhtml+xml" },
  580. { ".xhtml", "application/xhtml+xml" },
  581. { ".xla", "application/vnd.ms-excel" },
  582. { ".xlam", "application/vnd.ms-excel.addin.macroEnabled.12" },
  583. { ".xlc", "application/vnd.ms-excel" },
  584. { ".xlm", "application/vnd.ms-excel" },
  585. { ".xls", "application/vnd.ms-excel" },
  586. { ".xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12" },
  587. { ".xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12" },
  588. { ".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" },
  589. { ".xlt", "application/vnd.ms-excel" },
  590. { ".xltm", "application/vnd.ms-excel.template.macroEnabled.12" },
  591. { ".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template" },
  592. { ".xlw", "application/vnd.ms-excel" },
  593. { ".xml", "text/xml" },
  594. { ".xof", "x-world/x-vrml" },
  595. { ".xpm", "image/x-xpixmap" },
  596. { ".xps", "application/vnd.ms-xpsdocument" },
  597. { ".xsd", "text/xml" },
  598. { ".xsf", "text/xml" },
  599. { ".xsl", "text/xml" },
  600. { ".xslt", "text/xml" },
  601. { ".xsn", "application/octet-stream" },
  602. { ".xtp", "application/octet-stream" },
  603. { ".xwd", "image/x-xwindowdump" },
  604. { ".z", "application/x-compress" },
  605. { ".zip", "application/x-zip-compressed" }
  606. };
  607. #endregion
  608. }
  609. }
  610. }