Add bounds checking and repeated/additional hdrs
Close client socket on error
Merge pull request #1 from ld9999999999/master

Bounds checking and generic headers