集册 Java实例教程 是可重试的HTTP响应代码

是可重试的HTTP响应代码

欢马劈雪     最近更新时间:2020-01-02 10:19:05

410
是可重试的HTTP响应代码


//package com.nowjava;
/* 来自 时 代 J a v a - N o w J a v a . c o m*/

public class Main {

    public static boolean isResponseCodeRetryable(int responseCode) {

        if (responseCode >= 400 && responseCode <= 499) { // 4xx

            if (responseCode == 408 // Request Timeout

            ) {

                return true;

            } else {

                return false;

            }

        } else if (responseCode >= 500 && responseCode <= 599) { // 5xx

            if (responseCode == 500 || // Internal Server Error

                    responseCode == 505 || // HTTP Version Not Supported

                    responseCode == 506 // Variant Also Negotiates (RFC 2295)

            ) {

                return false;

            } else 
展开阅读全文