HttpURLConnection getResponseCode()在代码中返回200,但在开发工具检查器中实际上为500

时间:2019-04-29 07:38:16

标签: java selenium httpurlconnection

运行脚本时,我正在使用HttpURLConnection测试断开的链接,我收到的响应代码为200,但实际上为500

    Request URL: https://rb-upgrade.extranet-system.com/v2/social/rooms
    Request Method: GET
    Status Code: 500 
    Remote Address: 54.79.47.209:443
    Referrer Policy: no-referrer-when-downgrade
    HttpURLConnection connection = (HttpURLConnection) new URL("https://rb-upgrade.extranet-system.com/v2/social/rooms").openConnection();

    connection.setRequestMethod("GET");
    connection.connect();
    int iresponsecode = connection.getResponseCode();

我得到的int responsecode为200

如何确保我得到正确的响应代码,如开发者工具中所示。谢谢您的时间

0 个答案:

没有答案