Last active
September 22, 2021 06:27
-
-
Save sogaiu/d49bb541805934360dc38a7ccc576550 to your computer and use it in GitHub Desktop.
number special and chunked encoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let [chunked | |
# https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Encoded_data | |
(string "4\r\n" | |
"Wiki\r\n" | |
"6\r\n" | |
"pedia \r\n" | |
"E\r\n" | |
"in \r\n" | |
"\r\n" | |
"chunks.\r\n" | |
"0\r\n" | |
"\r\n")] | |
(peg/match ~(some (sequence | |
(number :h+ 16 :length) | |
"\r\n" | |
(capture | |
(lenprefix (backref :length) | |
1)) | |
"\r\n")) | |
chunked)) | |
# => @[4 "Wiki" 6 "pedia " 14 "in \r\n\r\nchunks." 0 ""] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment