org.xsocket.connection.http.client.IHttpClientEndpoint Maven / Gradle / Ivy
/*
* Copyright (c) xsocket.org, 2006 - 2008. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Please refer to the LGPL license at: http://www.gnu.org/copyleft/lesser.txt
* The latest copy of this software may be found on http://www.xsocket.org/
*/
package org.xsocket.connection.http.client;
import java.io.Closeable;
import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import org.xsocket.connection.http.BodyDataSink;
import org.xsocket.connection.http.HttpRequest;
import org.xsocket.connection.http.HttpRequestHeader;
import org.xsocket.connection.http.HttpResponse;
import org.xsocket.connection.http.server.IHttpRequestHandler;
/**
* represents the client side endpoint of a http connection
*
*
* @author [email protected]
*/
public interface IHttpClientEndpoint extends Closeable {
public static final boolean DEFAULT_AUTOHANDLE_100CONTINUE_RESPONSE = true;
/**
* set the receive time out by performing the call or send method
*
* @param receiveTimeout the receive timeout
*/
public void setResponseTimeoutSec(int receiveTimeout);
/**
* returns the receive timeout
*
* @return the receive timeout
*/
public int getResponseTimeoutSec();
/**
* performs a request. This method blocks until the response (header)
* is received
*
* @param request the request
* @return the response
* @throws IOException if an exception occurs
* @throws ConnectException if an error occurred while attempting to connect to a remote address and port.
* @throws SocketTimeoutException if the received timeout is exceed
*/
public HttpResponse call(HttpRequest request) throws IOException, ConnectException, SocketTimeoutException;
/**
* send the request. If the content-length header is not set, the message will send
* in chunked mode
*
* @param requestHeader the request header
* @param responseHandler the response handler (supported: {@link IHttpRequestHandler}, {@link IHttpResponseTimeoutHandler})
* @return the body handle to write
* @throws ConnectException if an error occurred while attempting to connect to a remote address and port.
* @throws IOException if an exception occurs
*/
public BodyDataSink send(HttpRequestHeader requestHeader, IHttpResponseHandler responseHandler) throws IOException, ConnectException;
/**
* send the request in a plain body mode
*
* @param requestHeader the request header
* @param contentLength the content length
* @param responseHandler the response handler (supported: {@link IHttpRequestHandler}, {@link IHttpResponseTimeoutHandler})
* @return the body handle to write
* @throws ConnectException if an error occurred while attempting to connect to a remote address and port.
* @throws IOException if an exception occurs
*/
public BodyDataSink send(HttpRequestHeader requestHeader, int contentLength, IHttpResponseHandler responseHandler) throws IOException, ConnectException;
/**
* send the request
*
* @param request the request
* @param responseHandler the response handler (supported: {@link IHttpRequestHandler}, {@link IHttpResponseTimeoutHandler})
* @throws ConnectException if an error occurred while attempting to connect to a remote address and port.
* @throws IOException if an exception occurs
*/
public void send(HttpRequest request, IHttpResponseHandler responseHandler) throws IOException, ConnectException;
/**
* returns the id
*
* @return id
*/
public String getId();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy