Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active September 22, 2021 06:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sogaiu/d49bb541805934360dc38a7ccc576550 to your computer and use it in GitHub Desktop.
Save sogaiu/d49bb541805934360dc38a7ccc576550 to your computer and use it in GitHub Desktop.
number special and chunked encoding
(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