
001package ca.uhn.fhir.rest.client.api; 002 003/* 004 * #%L 005 * HAPI FHIR - Core Library 006 * %% 007 * Copyright (C) 2014 - 2023 Smile CDR, Inc. 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 * 035 * @param theName the header name 036 * @param theValue the header value 037 */ 038 void addHeader(String theName, String theValue); 039 040 /** 041 * Execute the request 042 * 043 * @return the response 044 */ 045 IHttpResponse execute() throws IOException; 046 047 /** 048 * @return all request headers in lower case. Note that this method 049 * returns an <b>immutable</b> Map 050 */ 051 Map<String, List<String>> getAllHeaders(); 052 053 /** 054 * Return the request body as a string. 055 * If this is not supported by the underlying technology, null is returned 056 * 057 * @return a string representation of the request or null if not supported or empty. 058 */ 059 String getRequestBodyFromStream() throws IOException; 060 061 /** 062 * Return the request URI, or null 063 * 064 * @see #getUri() 065 */ 066 String getUri(); 067 068 /** 069 * Modify the request URI, or null 070 * 071 * @see #setUrlSource(UrlSourceEnum) 072 */ 073 void setUri(String theUrl); 074 075 /** 076 * Return the HTTP verb (e.g. "GET") 077 */ 078 String getHttpVerbName(); 079 080 /** 081 * Remove any headers matching the given name 082 * 083 * @param theHeaderName The header name, e.g. "Accept" (must not be null or blank) 084 */ 085 void removeHeaders(String theHeaderName); 086 087 /** 088 * Where was the URL from? 089 * 090 * @since 5.0.0 091 */ 092 UrlSourceEnum getUrlSource(); 093 094 /** 095 * Where was the URL from? 096 * 097 * @since 5.0.0 098 */ 099 void setUrlSource(UrlSourceEnum theUrlSource); 100 101}