is HTTP Response Code Retryable - Java Network

Java examples for Network:Http

Description

is HTTP Response Code Retryable

Demo Code


//package com.java2s;

public class Main {
    public static boolean isResponseCodeRetryable(int responseCode) {
        if (responseCode >= 400 && responseCode <= 499) { // 4xx
            if (responseCode == 408 // Request Timeout
            ) {/* ww w  .  j  av a  2  s.com*/
                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 {
                return true;
            }
        } else {
            return false;
        }
    }
}

Related Tutorials