001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.http.response;
014
015import static org.apache.juneau.http.response.UseProxy.*;
016
017import java.net.*;
018import java.util.*;
019
020import org.apache.http.*;
021import org.apache.http.Header;
022import org.apache.juneau.annotation.*;
023import org.apache.juneau.http.*;
024import org.apache.juneau.http.annotation.*;
025import org.apache.juneau.http.header.*;
026import org.apache.juneau.internal.*;
027
028/**
029 * Represents an <c>HTTP 305 Use Proxy</c> response.
030 *
031 * <p>
032 * The requested resource is available only through a proxy, the address for which is provided in the response.
033 * Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.
034 *
035 * <h5 class='section'>See Also:</h5><ul>
036 *    <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a>
037 * </ul>
038 */
039@Response
040@StatusCode(STATUS_CODE)
041@Schema(description=REASON_PHRASE)
042@FluentSetters
043public class UseProxy extends BasicHttpResponse {
044
045   /** HTTP status code */
046   public static final int STATUS_CODE = 305;
047
048   /** Reason phrase */
049   public static final String REASON_PHRASE = "Use Proxy";
050
051   private static final BasicStatusLine STATUS_LINE = BasicStatusLine.create(STATUS_CODE, REASON_PHRASE);
052
053   /** Default unmodifiable instance */
054   public static final UseProxy INSTANCE = new UseProxy().setUnmodifiable();
055
056   /**
057    * Constructor.
058    */
059   public UseProxy() {
060      super(STATUS_LINE);
061   }
062
063   /**
064    * Copy constructor.
065    *
066    * @param copyFrom The bean to copy from.
067    */
068   public UseProxy(UseProxy copyFrom) {
069      super(copyFrom);
070   }
071
072   /**
073    * Constructor.
074    *
075    * <p>
076    * This is the constructor used when parsing an HTTP response.
077    *
078    * @param response The HTTP response to copy from.  Must not be <jk>null</jk>.
079    * @throws AssertionError If HTTP response status code does not match what was expected.
080    */
081   public UseProxy(HttpResponse response) {
082      super(response);
083      assertStatusCode(response);
084   }
085
086   /**
087    * Creates a builder for this class initialized with the contents of this bean.
088    *
089    * @return A new builder bean.
090    */
091   public UseProxy copy() {
092      return new UseProxy(this);
093   }
094
095   // <FluentSetters>
096
097   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
098   public UseProxy setContent(String value) {
099      super.setContent(value);
100      return this;
101   }
102
103   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
104   public UseProxy setContent(HttpEntity value) {
105      super.setContent(value);
106      return this;
107   }
108
109   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
110   public UseProxy setHeader2(Header value) {
111      super.setHeader2(value);
112      return this;
113   }
114
115   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
116   public UseProxy setHeader2(String name, String value) {
117      super.setHeader2(name, value);
118      return this;
119   }
120
121   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
122   public UseProxy setHeaders(List<Header> values) {
123      super.setHeaders(values);
124      return this;
125   }
126
127   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
128   public UseProxy setHeaders(HeaderList value) {
129      super.setHeaders(value);
130      return this;
131   }
132
133   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
134   public UseProxy setHeaders2(Header...values) {
135      super.setHeaders2(values);
136      return this;
137   }
138
139   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
140   public UseProxy setLocale2(Locale value) {
141      super.setLocale2(value);
142      return this;
143   }
144
145   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
146   public UseProxy setLocation(String value) {
147      super.setLocation(value);
148      return this;
149   }
150
151   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
152   public UseProxy setLocation(URI value) {
153      super.setLocation(value);
154      return this;
155   }
156
157   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
158   public UseProxy setProtocolVersion(ProtocolVersion value) {
159      super.setProtocolVersion(value);
160      return this;
161   }
162
163   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
164   public UseProxy setReasonPhrase2(String value) {
165      super.setReasonPhrase2(value);
166      return this;
167   }
168
169   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
170   public UseProxy setReasonPhraseCatalog(ReasonPhraseCatalog value) {
171      super.setReasonPhraseCatalog(value);
172      return this;
173   }
174
175   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
176   public UseProxy setStatusCode2(int value) {
177      super.setStatusCode2(value);
178      return this;
179   }
180
181   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
182   public UseProxy setStatusLine(BasicStatusLine value) {
183      super.setStatusLine(value);
184      return this;
185   }
186
187   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
188   public UseProxy setUnmodifiable() {
189      super.setUnmodifiable();
190      return this;
191   }
192
193   // </FluentSetters>
194}