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.client5.http.io; 29 30 import java.io.IOException; 31 32 import org.apache.hc.core5.annotation.Contract; 33 import org.apache.hc.core5.annotation.ThreadingBehavior; 34 import org.apache.hc.core5.http.ClassicHttpRequest; 35 import org.apache.hc.core5.http.ClassicHttpResponse; 36 import org.apache.hc.core5.http.HttpException; 37 import org.apache.hc.core5.http.impl.io.HttpRequestExecutor; 38 import org.apache.hc.core5.http.protocol.HttpContext; 39 import org.apache.hc.core5.io.ModalCloseable; 40 import org.apache.hc.core5.util.Timeout; 41 42 /** 43 * Client endpoint leased from a connection manager. Client points can be used 44 * to execute HTTP requests. 45 * <p> 46 * Once the endpoint is no longer needed it MUST be released with {@link #close(org.apache.hc.core5.io.CloseMode)} )}. 47 * </p> 48 * 49 * @since 5.0 50 */ 51 @Contract(threading = ThreadingBehavior.SAFE) 52 public abstract class ConnectionEndpoint implements ModalCloseable { 53 54 /** 55 * Executes HTTP request using the provided request executor. 56 * <p> 57 * Once the endpoint is no longer needed it MUST be released with {@link #close(org.apache.hc.core5.io.CloseMode)}. 58 * </p> 59 * 60 * @param id unique operation ID or {@code null}. 61 * @param request the request message. 62 * @param executor the request executor. 63 * @param context the execution context. 64 */ 65 public abstract ClassicHttpResponse execute( 66 String id, 67 ClassicHttpRequest request, 68 HttpRequestExecutor executor, 69 HttpContext context) throws IOException, HttpException; 70 71 /** 72 * Determines if the connection to the remote endpoint is still open and valid. 73 */ 74 public abstract boolean isConnected(); 75 76 /** 77 * Sets the socket timeout value. 78 * 79 * @param timeout timeout value 80 */ 81 public abstract void setSocketTimeout(Timeout timeout); 82 83 }