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 or {@code null} if the connection has been closed 51 * by the opposite endpoint. 52 * @throws HttpException in case of HTTP protocol violation 53 * @throws IOException in case of an I/O error 54 */ 55 ClassicHttpRequest receiveRequestHeader() 56 throws HttpException, IOException; 57 58 /** 59 * Receives the next request entity available from this connection and attaches it to 60 * an existing request. 61 * @param request the request to attach the entity to. 62 * @throws HttpException in case of HTTP protocol violation 63 * @throws IOException in case of an I/O error 64 */ 65 void receiveRequestEntity(ClassicHttpRequest request) 66 throws HttpException, IOException; 67 68 /** 69 * Sends the response line and headers of a response over this connection. 70 * @param response the response whose headers to send. 71 * @throws HttpException in case of HTTP protocol violation 72 * @throws IOException in case of an I/O error 73 */ 74 void sendResponseHeader(ClassicHttpResponse response) 75 throws HttpException, IOException; 76 77 /** 78 * Sends the response entity of a response over this connection. 79 * @param response the response whose entity to send. 80 * @throws HttpException in case of HTTP protocol violation 81 * @throws IOException in case of an I/O error 82 */ 83 void sendResponseEntity(ClassicHttpResponse response) 84 throws HttpException, IOException; 85 86 }