Merge pull request #4308 from pks-t/pks/header-state-machine patch_parse: implement state machine for parsing patch headers