View Javadoc
1   /*
2    * Copyright 2002-2014 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.http.client;
18  
19  import java.io.Closeable;
20  import java.io.IOException;
21  
22  import org.springframework.http.HttpInputMessage;
23  import org.springframework.http.HttpStatus;
24  
25  /**
26   * Represents a client-side HTTP response.
27   * Obtained via an calling of the {@link ClientHttpRequest#execute()}.
28   *
29   * <p>A {@code ClientHttpResponse} must be {@linkplain #close() closed},
30   * typically in a {@code finally} block.
31   *
32   * @author Arjen Poutsma
33   * @since 3.0
34   */
35  public interface ClientHttpResponse extends HttpInputMessage, Closeable {
36  
37  	/**
38  	 * Return the HTTP status code of the response.
39  	 * @return the HTTP status as an HttpStatus enum value
40  	 * @throws IOException in case of I/O errors
41  	 */
42  	HttpStatus getStatusCode() throws IOException;
43  
44  	/**
45  	 * Return the HTTP status code of the response as integer
46  	 * @return the HTTP status as an integer
47  	 * @throws IOException in case of I/O errors
48  	 */
49  	int getRawStatusCode() throws IOException;
50  
51  	/**
52  	 * Return the HTTP status text of the response.
53  	 * @return the HTTP status text
54  	 * @throws IOException in case of I/O errors
55  	 */
56  	String getStatusText() throws IOException;
57  
58  	/**
59  	 * Close this response, freeing any resources created.
60  	 */
61  	@Override
62  	void close();
63  
64  }