http message serialization routines rewritten from scratch