Code factorization
Fixed bad request parsing