rewrote the HTTP encoding, and missing functions