Lesson 6: Content length

Contents
  • 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

Hello!\n

into this Haskell expression:

Response
  (StatusLine http_1_1 status200 reasonOK)
  [plainTextAsciiHeader,
    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.