Skip to content

Commit d423e91

Browse files
committed
FEAT: support for optional Brotli encoding in HTTP scheme
1 parent a7c2ccd commit d423e91

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/mezz/prot-http.reb

+10-8
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ REBOL [
1212
Licensed under the Apache License, Version 2.0
1313
See: http://www.apache.org/licenses/LICENSE-2.0
1414
}
15-
Version: 0.5.1
16-
Date: 12-Jun-2023
17-
File: %prot-http.r
15+
Version: 0.5.2
16+
Date: 22-Jul-2023
17+
File: %prot-http.r3
1818
Purpose: {
1919
This program defines the HTTP protocol scheme for REBOL 3.
2020
}
@@ -39,6 +39,7 @@ REBOL [
3939
0.4.1 13-Jun-2022 "Oldes" "FIX: Using `query` on URL sometimes reports `date: none`"
4040
0.5.0 18-Jul-2022 "Oldes" "FEAT: `read/seek` and `read/all` implementation"
4141
0.5.1 12-Jun-2023 "Oldes" "FEAT: anonymize authentication tokens in log"
42+
0.5.2 22-Jul-2023 "Oldes" "FEAT: support for optional Brotli encoding"
4243
]
4344
]
4445

@@ -673,12 +674,10 @@ decode-result: func[
673674
/local body content-type code-page encoding
674675
][
675676
if encoding: select result/2 'Content-Encoding [
676-
either find ["gzip" "deflate"] encoding [
677+
either find ["gzip" "deflate" "br"] encoding [
678+
if encoding == "br" [encoding: 'brotli]
677679
try/with [
678-
result/3: switch encoding [
679-
"gzip" [ decompress result/3 'gzip]
680-
"deflate" [ decompress result/3 'deflate]
681-
]
680+
result/3: decompress result/3 to word! encoding
682681
][
683682
sys/log/info 'HTTP ["Failed to decode data using:^[[22m" encoding]
684683
return result
@@ -959,6 +958,9 @@ sys/make-scheme [
959958
;@@ One can set above value for example to: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
960959
;@@ And so pretend that request is coming from Chrome on Windows10
961960
]
961+
if find system/catalog/compressions 'brotli [
962+
append headers/Accept-Encoding ",br"
963+
]
962964
]
963965

964966
sys/make-scheme/with [

0 commit comments

Comments
 (0)