From d6e131e60cb601c2cd0ce28518f8ebadba1c863c Mon Sep 17 00:00:00 2001 From: Ciprian Dorin Craciun Date: Mon, 20 Dec 2021 22:20:43 +0200 Subject: [PATCH] [archiver] Add mime types aliases for auto detection. --- examples/hello-world.cdb | Bin 2446 -> 2730 bytes examples/hello-world.cdb-dump | 56 +++++++++++++++++++------------ sources/cmd/archiver/archiver.go | 5 +++ sources/lib/common/mime.go | 6 ++++ 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/examples/hello-world.cdb b/examples/hello-world.cdb index 5d5b9d7fb47938d96d5455a29395b0fc6287c7c9..5d94f6f4446d4433faeeb6a3b47e4686ad1add0c 100644 GIT binary patch literal 2730 zcmaFG$p8kgD4>~uCj5fxrw0wPkBbZ9ZenPVdMT*-Q5q6%Ln$0U@uvlizmY(L{A&gE z?Z3{xPq5eHD% z0El7Y84zi652!jQKN-q5hVYF{q5Kq(eqJDkndgz3lasGdo?n!cqR0iaHwSL7F;txi zn!QkS4T-eZ5bW+CguN!!N~w7zMVYC^N> z)qu5jQVs<& zp6%RIkoX~qvW*N#{G!hR-W!qh&lBF6)(hnC_;CBm4J2`xd6${_h02liUj_2t1NlGA ZKAkd068{b4uSep;^#2LYtqBC03jh{6;h+Ej literal 2446 zcmd<%WB>y`EHo2PMh+^Dj|QpJgQ_Ej2C27$swamA>Gy-`AEkkTG04IL6hCp$_!*_a z(K8wzgD5?K(q|sjJ)<-veGa8?0L5P&H2y|uNc`ao2T*wRLBk83W(3Ny0&%gCfstV% zGmr(sX;%7%Rz@IJDG=vc89FB>XQb*n=jW9a<>y!_6qF|AWG3qbMolGKV4{eqmt z%sgv_z?c97oaj(2chPPPc=LzpjyM`owZ7a|zNc=y+xiwpWd;o&GyOjU{ diff --git a/examples/hello-world.cdb-dump b/examples/hello-world.cdb-dump index 9e9ccad..15e783e 100644 --- a/examples/hello-world.cdb-dump +++ b/examples/hello-world.cdb-dump @@ -1,41 +1,55 @@ -+1,5 -s -2021a ++6,14 +schema +kawipiko-2021b -+3,3 ++3,16 f:/ -1:2 +m0000001d0000002 -+3,117 -m:1 -Cache-Control: public, immutable, max-age=3600 -Content-Encoding: identity -Content-Type: text/plain; charset=utf-8 ++8,48 +m0000001 +h0000017H0000001h000001cH0000003h0000025H000000d - -+3,13 -c:2 ++8,13 +d0000002 Hello world! -+4,3 ++3,16 +l:/ +m0000003d0000004 + ++8,48 +m0000003 +h0000017H0000001h000001cH0000003h0000025H0000012 + ++8,82 +d0000004 +{"entries":[{"name":"index.txt","type":"file","size":13}],"indices":["index.txt"]} + ++4,16 f:/* -1:2 +m0000001d0000002 -+8,3 ++8,16 f:/index -1:2 +m0000001d0000002 -+12,3 ++12,16 f:/index.txt -1:2 +m0000001d0000002 -+2,23 -fi ++8,23 +F0000001 / /* /index /index.txt ++8,2 +L0000001 +/ + + diff --git a/sources/cmd/archiver/archiver.go b/sources/cmd/archiver/archiver.go index f82716e..a9559b1 100644 --- a/sources/cmd/archiver/archiver.go +++ b/sources/cmd/archiver/archiver.go @@ -541,6 +541,11 @@ func prepareDataContent (_context *context, _pathResolved string, _pathInArchive } if (_dataType == "") { _dataType = http.DetectContentType (_dataContent) + if _dataType != "" { + if _dataType_0, _ := MimeTypesAliases[_dataType]; _dataType_0 != "" { + _dataType = _dataType_0 + } + } } if _dataType == "" { _dataType = MimeTypeRaw diff --git a/sources/lib/common/mime.go b/sources/lib/common/mime.go index 26bf4ba..caf4b20 100644 --- a/sources/lib/common/mime.go +++ b/sources/lib/common/mime.go @@ -193,3 +193,9 @@ var MimeTypes = []string { } + + +var MimeTypesAliases = map[string]string { + "text/xml; charset=utf-8" : MimeTypeXml, + } +