Split HTTP header parsing into a common function.