即使服务器发回错误,WebView也不会收到错误。

我尝试访问的网页发回403错误。我期望WebViewClient会收到错误,但不会。它不应该出错吗?
engine.setWebViewClient(new WebViewClient() {
        boolean error = false;
        public void onReceivedError(WebView view, int errorCode,
                String description, String failingUrl) {

            //IT DOESN\'T COME HERE even IF SERVER SENDS BACK 403 ERROR
        }
    });
看起来,我将不得不使用HttpRequest读取响应并解析响应以检查发生了什么。还有其他方法吗?我可以从WebView中检查标题吗?     
已邀请:
我必须使用两个请求来实现要求。第一个请求检查凭据是否正确,并且没有错误(使用HttpURLConnection)。仅当响应正常时,我才加载Web视图。
protected Void doInBackground(final String... url) {
        boolean failed = false;
        int error = 0;

        try {
            URL urlToLoad = new URL(url[0]);
            HttpURLConnection conn = (HttpURLConnection) urlToLoad
                    .openConnection();
            int response = conn.getResponseCode();
            if (response != HttpURLConnection.HTTP_OK) {
                error = response;
                failed = true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (!failed) {
            webView.loadUrl(url[0]);
        } else {
            handler.post(hideProgressRunnable);
            connecting = false;
            showError(ErrorMap.getErrorForHttpCode(error));
        }
        return null;
    }
    

要回复问题请先登录注册