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.Continue.*;
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 100 Continue</c> response.
030 *
031 * <p>
032 * The server has received the request headers and the client should proceed to send the request body (in the case of a request for which a body needs to be sent; for example, a POST request).
033 * Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.
034 * To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request and receive a 100 Continue status code in response before sending the body.
035 * If the client receives an error code such as 403 (Forbidden) or 405 (Method Not Allowed) then it shouldn't send the request's body.
036 * The response 417 Expectation Failed indicates that the request should be repeated without the Expect header as it indicates that the server doesn't support expectations (this is the case, for example, of HTTP/1.0 servers).
037 *
038 * <h5 class='section'>See Also:</h5><ul>
039 *    <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a>
040 * </ul>
041 */
042@Response
043@StatusCode(STATUS_CODE)
044@Schema(description=REASON_PHRASE)
045@FluentSetters
046public class Continue extends BasicHttpResponse {
047
048   /** HTTP status code */
049   public static final int STATUS_CODE = 100;
050
051   /** Reason phrase */
052   public static final String REASON_PHRASE = "Continue";
053
054   /** Default status line */
055   private static final BasicStatusLine STATUS_LINE = BasicStatusLine.create(STATUS_CODE, REASON_PHRASE);
056
057   /** Default unmodifiable instance */
058   public static final Continue INSTANCE = new Continue().setUnmodifiable();
059
060   /**
061    * Constructor.
062    */
063   public Continue() {
064      super(STATUS_LINE);
065   }
066
067   /**
068    * Copy constructor.
069    *
070    * @param copyFrom The bean to copy from.
071    */
072   public Continue(Continue copyFrom) {
073      super(copyFrom);
074   }
075
076   /**
077    * Constructor.
078    *
079    * <p>
080    * This is the constructor used when parsing an HTTP response.
081    *
082    * @param response The HTTP response to copy from.  Must not be <jk>null</jk>.
083    * @throws AssertionError If HTTP response status code does not match what was expected.
084    */
085   public Continue(HttpResponse response) {
086      super(response);
087      assertStatusCode(response);
088   }
089
090   /**
091    * Creates a builder for this class initialized with the contents of this bean.
092    *
093    * @return A new builder bean.
094    */
095   public Continue copy() {
096      return new Continue(this);
097   }
098
099   // <FluentSetters>
100
101   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
102   public Continue setContent(String value) {
103      super.setContent(value);
104      return this;
105   }
106
107   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
108   public Continue setContent(HttpEntity value) {
109      super.setContent(value);
110      return this;
111   }
112
113   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
114   public Continue setHeader2(Header value) {
115      super.setHeader2(value);
116      return this;
117   }
118
119   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
120   public Continue setHeader2(String name, String value) {
121      super.setHeader2(name, value);
122      return this;
123   }
124
125   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
126   public Continue setHeaders(List<Header> values) {
127      super.setHeaders(values);
128      return this;
129   }
130
131   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
132   public Continue setHeaders(HeaderList value) {
133      super.setHeaders(value);
134      return this;
135   }
136
137   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
138   public Continue setHeaders2(Header...values) {
139      super.setHeaders2(values);
140      return this;
141   }
142
143   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
144   public Continue setLocale2(Locale value) {
145      super.setLocale2(value);
146      return this;
147   }
148
149   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
150   public Continue setLocation(String value) {
151      super.setLocation(value);
152      return this;
153   }
154
155   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
156   public Continue setLocation(URI value) {
157      super.setLocation(value);
158      return this;
159   }
160
161   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
162   public Continue setProtocolVersion(ProtocolVersion value) {
163      super.setProtocolVersion(value);
164      return this;
165   }
166
167   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
168   public Continue setReasonPhrase2(String value) {
169      super.setReasonPhrase2(value);
170      return this;
171   }
172
173   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
174   public Continue setReasonPhraseCatalog(ReasonPhraseCatalog value) {
175      super.setReasonPhraseCatalog(value);
176      return this;
177   }
178
179   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
180   public Continue setStatusCode2(int value) {
181      super.setStatusCode2(value);
182      return this;
183   }
184
185   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
186   public Continue setStatusLine(BasicStatusLine value) {
187      super.setStatusLine(value);
188      return this;
189   }
190
191   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
192   public Continue setUnmodifiable() {
193      super.setUnmodifiable();
194      return this;
195   }
196
197   // </FluentSetters>
198}