checking if request.env has HTTP_ACCEPT header
addressing PR comments. Refactoring.