fix bugs and internal api to handle statusCode of HTTP response