001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.rest.client; 014 015import java.io.*; 016 017import org.apache.http.*; 018import org.apache.http.client.*; 019import org.apache.http.client.methods.*; 020 021/** 022 * Interface that allows you to override the handling of HTTP requests. 023 * 024 * <p> 025 * Providing this implementation is the equivalent to overriding the {@link RestClient#execute(HttpEntityEnclosingRequestBase)} 026 * and {@link RestClient#execute(HttpRequestBase)} methods. 027 * 028 * <p> 029 * This can also be accomplished by providing your own {@link RestClientBuilder#connectionManager(org.apache.http.conn.HttpClientConnectionManager)}, 030 * but this provides a simpler way of handling the requests yourself. 031 * 032 * <ul class='seealso'> 033 * <li class='jf'>{@link RestClient#RESTCLIENT_callHandler} 034 * <li class='jf'>{@link RestClientBuilder#callHandler(Class)} 035 * <li class='jf'>{@link RestClientBuilder#callHandler(RestCallHandler)} 036 * </ul> 037 * 038 * @deprecated Use {@link org.apache.juneau.rest.client2.RestCallHandler} class. 039 */ 040@Deprecated 041public interface RestCallHandler { 042 043 /** 044 * Execute the specified body request (e.g. POST/PUT). 045 * 046 * <p> 047 * Subclasses can override this method to provide specialized handling. 048 * 049 * @param req The HTTP request. 050 * @return The HTTP response. 051 * @throws IOException Stream exception occurred. 052 * @throws ClientProtocolException Signals an error in the HTTP protocol. 053 */ 054 HttpResponse execute(HttpEntityEnclosingRequestBase req) throws ClientProtocolException, IOException; 055 056 /** 057 * Execute the specified no-body request (e.g. GET/DELETE). 058 * 059 * <p> 060 * Subclasses can override this method to provide specialized handling. 061 * 062 * @param req The HTTP request. 063 * @return The HTTP response. 064 * @throws IOException Stream exception occurred. 065 * @throws ClientProtocolException Signals an error in the HTTP protocol. 066 */ 067 HttpResponse execute(HttpRequestBase req) throws ClientProtocolException, IOException; 068}