Mercurial > prosody-modules
annotate mod_http_favicon/mod_http_favicon.lua @ 3866:c0df50ce96f0
mod_rest: Handle internal http request errors early and then return
Skips over attempted parsing of the payload which usually failed since
the body is an error string like "connection refused", so this produced
useless errors.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 25 Jan 2020 20:22:12 +0100 |
parents | 1861d6ba6ff6 |
children |
rev | line source |
---|---|
740
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 module:depends("http"); |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local favicon = require"util.encodings".base64.decode[[ |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAA |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 AAAAAAD///8AsuD6TGrE95RiwfabYsH2m2TB9pmU1Phq+vz9A/38+wPx07xq67+emeq+nZvqvp2b |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 68GilPTfz0z///8AsuD6TACb8v8Am/L/AJvy/wCb8v8Am/L/AJvy/3TI94ntxqiJ35dh/9+XYf/f |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 l2H/35dh/9+XYf/fl2H/9N/PTGrE95QAm/L/AJvy/wCb8v8Am/L/AJvy/wCb8v8qq/PU5Kh61N+X |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 Yf/fl2H/35dh/9+XYf/fl2H/35dh/+vBopRiwfabAJvy/wCb8v8Am/L/AJvy/wCb8v8Am/L/Iqjz |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 3OOkdtzfl2H/35dh/9+XYf/fl2H/35dh/9+XYf/qvp2bYsH2mwCb8v8Am/L/AJvy/wCb8v8Am/L/ |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 AJvy/yKo89zjpHbc35dh/9+XYf/fl2H/35dh/9+XYf/fl2H/6r6dm2TB9pkAm/L/AJvy/wCb8v8A |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 m/L/AJvy/wCb8v8kqfPa46V32t+XYf/fl2H/35dh/9+XYf/fl2H/35dh/+u/npmU1PhqAJvy/wCb |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 8v8Am/L/AJvy/wCb8v8Am/L/Vrz2p+m5lqffl2H/35dh/9+XYf/fl2H/35dh/9+XYf/x07xq+vz9 |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 A3TI94kqq/PUIqjz3CKo89wkqfPaVrz2p+b0/Bf79O8X6bmWp+Old9rjpHbc46R23OSoetTtxqiJ |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 /fz7A/38+wPtxqiJ5Kh61OOkdtzjpHbc46V32um5lqf79O8X5vT8F1a89qckqfPaIqjz3CKo89wq |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 q/PUdMj3ifr8/QPx07xq35dh/9+XYf/fl2H/35dh/9+XYf/fl2H/6bmWp1a89qcAm/L/AJvy/wCb |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 8v8Am/L/AJvy/wCb8v+U1Phq67+emd+XYf/fl2H/35dh/9+XYf/fl2H/35dh/+Old9okqfPaAJvy |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 /wCb8v8Am/L/AJvy/wCb8v8Am/L/ZMH2meq+nZvfl2H/35dh/9+XYf/fl2H/35dh/9+XYf/jpHbc |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 Iqjz3ACb8v8Am/L/AJvy/wCb8v8Am/L/AJvy/2LB9pvqvp2b35dh/9+XYf/fl2H/35dh/9+XYf/f |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 l2H/46R23CKo89wAm/L/AJvy/wCb8v8Am/L/AJvy/wCb8v9iwfab68GilN+XYf/fl2H/35dh/9+X |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 Yf/fl2H/35dh/+SoetQqq/PUAJvy/wCb8v8Am/L/AJvy/wCb8v8Am/L/asT3lPTfz0zfl2H/35dh |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 /9+XYf/fl2H/35dh/9+XYf/txqiJdMj3iQCb8v8Am/L/AJvy/wCb8v8Am/L/AJvy/7Lg+kz///8A |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 9N/PTOvBopTqvp2b6r6dm+u/npnx07xq/fz7A/r8/QOU1PhqZMH2mWLB9ptiwfabasT3lLLg+kz/ |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 //8Aw8MAAIABAAAAAAAAAAAAAAAAAAAAAAAAgAEAAIGBAACBgQAAgAEAAAAAAAAAAAAAAAAAAAAA |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 AACAAQAAw8MAAA==]]; |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 local filename = module:get_option_string("favicon"); |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 if filename then |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 local fd = assert(module:load_resource(filename)); |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 favicon = assert(fd:read("*a")); |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 end |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 module:provides("http", { |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 default_path = "/favicon.ico"; |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 route = { |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 GET = { |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 headers = { |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 content_type = "image/x-icon"; |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 }; |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 body = favicon; |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 } |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 } |
1861d6ba6ff6
mod_http_favicon: Add, serves a favicon.ico
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 }); |