View Javadoc
1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  
28  package org.apache.http;
29  
30  import java.io.IOException;
31  
32  /**
33   * A server-side HTTP connection, which can be used for receiving
34   * requests and sending responses.
35   *
36   * @since 4.0
37   */
38  public interface HttpServerConnection extends HttpConnection {
39  
40      /**
41       * Receives the request line and all headers available from this connection.
42       * The caller should examine the returned request and decide if to receive a
43       * request entity as well.
44       *
45       * @return a new HttpRequest object whose request line and headers are
46       *         initialized.
47       * @throws HttpException in case of HTTP protocol violation
48       * @throws IOException in case of an I/O error
49       */
50      HttpRequest receiveRequestHeader()
51          throws HttpException, IOException;
52  
53      /**
54       * Receives the next request entity available from this connection and attaches it to
55       * an existing request.
56       * @param request the request to attach the entity to.
57       * @throws HttpException in case of HTTP protocol violation
58       * @throws IOException in case of an I/O error
59       */
60      void receiveRequestEntity(HttpEntityEnclosingRequest request)
61          throws HttpException, IOException;
62  
63      /**
64       * Sends the response line and headers of a response over this connection.
65       * @param response the response whose headers to send.
66       * @throws HttpException in case of HTTP protocol violation
67       * @throws IOException in case of an I/O error
68       */
69      void sendResponseHeader(HttpResponse response)
70          throws HttpException, IOException;
71  
72      /**
73       * Sends the response entity of a response over this connection.
74       * @param response the response whose entity to send.
75       * @throws HttpException in case of HTTP protocol violation
76       * @throws IOException in case of an I/O error
77       */
78      void sendResponseEntity(HttpResponse response)
79          throws HttpException, IOException;
80  
81      /**
82       * Sends all pending buffered data over this connection.
83       * @throws IOException in case of an I/O error
84       */
85      void flush()
86          throws IOException;
87  
88  }