use state machine to parse http request