Skip to content

Instantly share code, notes, and snippets.

@ChrisPritchard
Created January 8, 2020 00:56
Show Gist options
  • Save ChrisPritchard/7abb41d5d9405e84835b4ec303abeb2a to your computer and use it in GitHub Desktop.
Save ChrisPritchard/7abb41d5d9405e84835b4ec303abeb2a to your computer and use it in GitHub Desktop.
Simple console app that helps calculate the hex size for body content in a transfer-encoding request
open System
[<EntryPoint>]
let main argv =
printfn "enter lines and end with EOF\n"
let sep = "\r\n"
let rec builder acc =
let line = Console.ReadLine ()
if line.Contains "EOF" then
let final = line.Substring (0, line.IndexOf "EOF")
(acc + sep + final).TrimStart (sep.ToCharArray())
else
builder (acc + sep + line)
let body = builder ""
let hexlen = body.Length.ToString "X"
printfn "\ncopy between [START and END]\n\n[START\n%s\n%s\n0\n\nEND]" hexlen body
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment