HTTP Parsing code, from PatchProxy