Shuyi Chen | d7955ce | 2013-05-22 14:51:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2009 Mike Cumings |
| 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 com.kenai.jbosh; |
| 18 | |
| 19 | /** |
| 20 | * This class represents a complete HTTP response to a request made via |
| 21 | * a {@code HTTPSender} send request. Instances of this interface are |
| 22 | * intended to represent a deferred, future response, not necessarily a |
| 23 | * response which is immediately available. |
| 24 | */ |
| 25 | interface HTTPResponse { |
| 26 | |
| 27 | /** |
| 28 | * Close out any resources still held by the original request. The |
| 29 | * conversation may need to be aborted if the session it was a part of |
| 30 | * gets abruptly terminated. |
| 31 | */ |
| 32 | void abort(); |
| 33 | |
| 34 | /** |
| 35 | * Get the HTTP status code of the response (e.g., 200, 404, etc.). If |
| 36 | * the response has not yet been received from the remote server, this |
| 37 | * method should block until the response has arrived. |
| 38 | * |
| 39 | * @return HTTP status code |
| 40 | * @throws InterruptedException if interrupted while awaiting response |
| 41 | */ |
| 42 | int getHTTPStatus() throws InterruptedException, BOSHException; |
| 43 | |
| 44 | /** |
| 45 | * Get the HTTP response message body. If the response has not yet been |
| 46 | * received from the remote server, this method should block until the |
| 47 | * response has arrived. |
| 48 | * |
| 49 | * @return response message body |
| 50 | * @throws InterruptedException if interrupted while awaiting response |
| 51 | */ |
| 52 | AbstractBody getBody() throws InterruptedException, BOSHException; |
| 53 | |
| 54 | } |