Path: blob/master/src/java.base/share/classes/java/net/HttpRetryException.java
41152 views
/*1* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.net;2627import java.io.IOException;2829/**30* Thrown to indicate that a HTTP request needs to be retried31* but cannot be retried automatically, due to streaming mode32* being enabled.33*34* @author Michael McMahon35* @since 1.536*/37public class HttpRetryException extends IOException {38@java.io.Serial39private static final long serialVersionUID = -9186022286469111381L;4041/**42* The response code.43*/44private int responseCode;4546/**47* The URL to be redirected to.48*/49private String location;5051/**52* Constructs a new {@code HttpRetryException} from the53* specified response code and exception detail message54*55* @param detail the detail message.56* @param code the HTTP response code from server.57*/58public HttpRetryException(String detail, int code) {59super(detail);60responseCode = code;61}6263/**64* Constructs a new {@code HttpRetryException} with detail message65* responseCode and the contents of the Location response header field.66*67* @param detail the detail message.68* @param code the HTTP response code from server.69* @param location the URL to be redirected to70*/71public HttpRetryException(String detail, int code, String location) {72super (detail);73responseCode = code;74this.location = location;75}7677/**78* Returns the http response code79*80* @return The http response code.81*/82public int responseCode() {83return responseCode;84}8586/**87* Returns a string explaining why the http request could88* not be retried.89*90* @return The reason string91*/92public String getReason() {93return super.getMessage();94}9596/**97* Returns the value of the Location header field if the98* error resulted from redirection.99*100* @return The location string101*/102public String getLocation() {103return location;104}105}106107108