test-server: extract header parsing code