001package ca.uhn.fhir.rest.client.api;
002
003/*
004 * #%L
005 * HAPI FHIR - Core Library
006 * %%
007 * Copyright (C) 2014 - 2018 University Health Network
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import java.io.IOException;
024import java.util.List;
025import java.util.Map;
026
027/**
028 * Http Request. Allows addition of headers and execution of the request.
029 */
030public interface IHttpRequest {
031        
032        /**
033         * Add a header to the request
034         * @param theName the header name
035         * @param theValue the header value
036         */
037        void addHeader(String theName, String theValue);
038
039        /**
040         * Execute the request
041         * @return the response
042         */
043        IHttpResponse execute() throws IOException;
044
045        /**
046         * @return all request headers in lower case. Note that this method
047         * returns an <b>immutable</b> Map
048         */
049        Map<String, List<String>> getAllHeaders();
050
051        /**
052         * Return the request body as a string.
053         * If this is not supported by the underlying technology, null is returned 
054         * @return a string representation of the request or null if not supported or empty.
055         */
056        String getRequestBodyFromStream() throws IOException;
057
058        /**
059         * Return the request URI, or null
060         */
061        String getUri();
062        
063        /**
064         * Return the HTTP verb (e.g. "GET")
065         */
066        String getHttpVerbName();
067        
068}