parses HTTP header fields; returns 501 in case of erroneous RFC6455 handshake
implements buf_rwnd()