View Javadoc
1   package ca.uhn.fhir.rest.client.api;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2019 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import java.io.IOException;
24  import java.util.List;
25  import java.util.Map;
26  
27  /**
28   * Http Request. Allows addition of headers and execution of the request.
29   */
30  public interface IHttpRequest {
31  
32  	/**
33  	 * Add a header to the request
34  	 *
35  	 * @param theName  the header name
36  	 * @param theValue the header value
37  	 */
38  	void addHeader(String theName, String theValue);
39  
40  	/**
41  	 * Execute the request
42  	 *
43  	 * @return the response
44  	 */
45  	IHttpResponse execute() throws IOException;
46  
47  	/**
48  	 * @return all request headers in lower case. Note that this method
49  	 * returns an <b>immutable</b> Map
50  	 */
51  	Map<String, List<String>> getAllHeaders();
52  
53  	/**
54  	 * Return the request body as a string.
55  	 * If this is not supported by the underlying technology, null is returned
56  	 *
57  	 * @return a string representation of the request or null if not supported or empty.
58  	 */
59  	String getRequestBodyFromStream() throws IOException;
60  
61  	/**
62  	 * Return the request URI, or null
63  	 */
64  	String getUri();
65  
66  	/**
67  	 * Return the HTTP verb (e.g. "GET")
68  	 */
69  	String getHttpVerbName();
70  
71  	/**
72  	 * Remove any headers matching the given name
73  	 *
74  	 * @param theHeaderName The header name, e.g. "Accept" (must not be null or blank)
75  	 */
76  	void removeHeaders(String theHeaderName);
77  }