001/*-
002 * #%L
003 * HAPI FHIR - Core Library
004 * %%
005 * Copyright (C) 2014 - 2025 Smile CDR, Inc.
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package ca.uhn.fhir.rest.gclient;
021
022import ca.uhn.fhir.rest.api.CacheControlDirective;
023
024/**
025 * The non-FHIR bits of IClientExecutable.
026 *
027 * @param <T> the builder self type
028 * @param <Y> the result type
029 */
030public interface IClientHttpExecutable<T extends IClientHttpExecutable<?, Y>, Y> {
031
032        /**
033         * Sets the <code>Cache-Control</code> header value, which advises the server (or any cache in front of it)
034         * how to behave in terms of cached requests
035         */
036        T cacheControl(CacheControlDirective theCacheControlDirective);
037
038        /**
039         * Set an HTTP header. One
040         *
041         * <p>It is the responsibility of the caller to care for proper encoding of the header value, e.g.
042         * using Base64.</p>
043         * <p>This is a short-cut alternative to using a corresponding client interceptor</p>
044         * <p>It is a multi-valued header. Calling it multiple times will add to the list rather than replace the value</p>
045         *
046         * @param theHeaderName header name
047         * @param theHeaderValue header value
048         * @return
049         */
050        T withAdditionalHeader(String theHeaderName, String theHeaderValue);
051
052        /**
053         * Actually execute the client operation and return the result.
054         * @return The result of the HTTP operation
055         */
056        Y execute();
057
058        /**
059         * Specifies a custom <code>Accept</code> header that should be supplied with the
060         * request.
061         *
062         * @param theHeaderValue The header value, e.g. "application/json". If set to <code>null</code> or an empty string,
063         *                       the default Accept header will be used.
064         */
065        T accept(String theHeaderValue);
066}