Lesson 6: Content length

  • Header alteration
  • Case insensitivity
  • Content length
  • Testing

At the end of lesson 5, we turned this HTTP response

HTTP/1.1 200 OK
Content-Type: text/plain; charset=us-ascii
Content-Length: 7


into this Haskell expression:

  (StatusLine http_1_1 status200 reasonOK)
    contentLengthHeader (7 :: Integer)]
  (Just (asciiMessageBody "Hello!\n"))

There’s one more thing we want to improve: Let’s leave off that Content-Length header and have a function that adds it automatically.

Sign up for access to the full page, plus the complete archive and all the latest content.