Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Commit 6576294

Browse files
committed
Merge pull request #1741 from prb112/master
Updates to Code for Headers
2 parents 6668c1e + ed0e727 commit 6576294

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/ClientService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,14 @@ protected void prepareRequest(HttpClient httpClient, HttpRequestBase httpRequest
12501250
if(appKey != null){
12511251
httpRequestBase.addHeader(APPKEY,appKey);
12521252
}
1253+
1254+
//Adds the Headers to the httpRequestBase
1255+
java.util.HashMap<String,String> headers = ((com.ibm.sbt.services.endpoints.AbstractEndpoint) endpoint).getHeaders();
1256+
java.util.Set<String> headerNames = headers.keySet();
1257+
for(String headerName : headerNames){
1258+
String headerVal = headers.get(headerName);
1259+
httpRequestBase.addHeader(headerName,headerVal);
1260+
}
12531261
}
12541262

12551263

sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/endpoints/AbstractEndpoint.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,45 @@ public abstract class AbstractEndpoint implements Endpoint, Cloneable {
9494
//Adds support for the API Management feature
9595
private static final String HEADER_APIM_SESSION_ID = "apim-session-id";
9696
private String apiSessionId = "";
97+
98+
//Adds support for the X-LConn-RunAs header
99+
public static final String HEADER_X_LCONN_RUNAS = "X-LConn-RunAs";
100+
private static final int AVG_HEADER_COUNT = 2;
101+
private java.util.HashMap<String,String> headers = new java.util.HashMap<String,String>(AVG_HEADER_COUNT);
97102

98103
public AbstractEndpoint() {
99104
}
100105

106+
/**
107+
* clears the headers which are used to make requests for the endpoint
108+
*/
109+
public void clearHeaders(){
110+
headers.clear();
111+
}
112+
113+
/**
114+
* the map with the headers
115+
*
116+
* @return {java.util.HashMap<String,String>} header
117+
*/
118+
public java.util.HashMap<String,String> getHeaders(){
119+
return headers;
120+
}
121+
122+
/**
123+
* add the header with the name:value to the headers map
124+
*/
125+
public void addHeader(String headerName, String headerValue){
126+
headers.put(headerName,headerValue);
127+
}
128+
129+
/**
130+
* removes the header with the given name
131+
*/
132+
public void remove(String headerName){
133+
headers.remove(headerName);
134+
}
135+
101136
/**
102137
* sets the api session id
103138
*/

0 commit comments

Comments
 (0)