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.hc.core5.http.io;
29  
30  import java.io.IOException;
31  
32  import org.apache.hc.core5.http.ClassicHttpRequest;
33  import org.apache.hc.core5.http.ClassicHttpResponse;
34  import org.apache.hc.core5.http.HttpException;
35  
36  /**
37   * A server-side HTTP connection, which can be used for receiving
38   * requests and sending responses.
39   *
40   * @since 4.0
41   */
42  public interface HttpServerConnection extends BHttpConnection {
43  
44      /**
45       * Receives the request line and all headers available from this connection.
46       * The caller should examine the returned request and decide if to receive a
47       * request entity as well.
48       *
49       * @return a new HttpRequest object whose request line and headers are
50       *         initialized.
51       * @throws HttpException in case of HTTP protocol violation
52       * @throws IOException in case of an I/O error
53       */
54      ClassicHttpRequest receiveRequestHeader()
55          throws HttpException, IOException;
56  
57      /**
58       * Receives the next request entity available from this connection and attaches it to
59       * an existing request.
60       * @param request the request to attach the entity to.
61       * @throws HttpException in case of HTTP protocol violation
62       * @throws IOException in case of an I/O error
63       */
64      void receiveRequestEntity(ClassicHttpRequest request)
65          throws HttpException, IOException;
66  
67      /**
68       * Sends the response line and headers of a response over this connection.
69       * @param response the response whose headers to send.
70       * @throws HttpException in case of HTTP protocol violation
71       * @throws IOException in case of an I/O error
72       */
73      void sendResponseHeader(ClassicHttpResponse response)
74          throws HttpException, IOException;
75  
76      /**
77       * Sends the response entity of a response over this connection.
78       * @param response the response whose entity to send.
79       * @throws HttpException in case of HTTP protocol violation
80       * @throws IOException in case of an I/O error
81       */
82      void sendResponseEntity(ClassicHttpResponse response)
83          throws HttpException, IOException;
84  
85  }