http_reader: improve robustness of header reading