commom implementation of parse_request