added support for custom headers and statusCode