Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/net/HttpRetryException.java
38829 views
/*1* Copyright (c) 2004, 2013, 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*/37public38class HttpRetryException extends IOException {39private static final long serialVersionUID = -9186022286469111381L;4041private int responseCode;42private String location;4344/**45* Constructs a new {@code HttpRetryException} from the46* specified response code and exception detail message47*48* @param detail the detail message.49* @param code the HTTP response code from server.50*/51public HttpRetryException(String detail, int code) {52super(detail);53responseCode = code;54}5556/**57* Constructs a new {@code HttpRetryException} with detail message58* responseCode and the contents of the Location response header field.59*60* @param detail the detail message.61* @param code the HTTP response code from server.62* @param location the URL to be redirected to63*/64public HttpRetryException(String detail, int code, String location) {65super (detail);66responseCode = code;67this.location = location;68}6970/**71* Returns the http response code72*73* @return The http response code.74*/75public int responseCode() {76return responseCode;77}7879/**80* Returns a string explaining why the http request could81* not be retried.82*83* @return The reason string84*/85public String getReason() {86return super.getMessage();87}8889/**90* Returns the value of the Location header field if the91* error resulted from redirection.92*93* @return The location string94*/95public String getLocation() {96return location;97}98}99100101