-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponseHeader.cls
36 lines (30 loc) · 1.22 KB
/
responseHeader.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public class responseHeader {
public static Map<String, String> getall(HTTPResponse res) {
//get the list of header names (keys)
string[] headerkeys = res.getHeaderKeys();
system.debug(headerkeys);
//create an object to store your header key-value pairs
Map<string, string> headers = new map<string, string>();
//iterate through they keys, and populate your map
for(string s : headerkeys){
if (s != null) {
headers.put(s,res.getHeader(s));
system.debug('header: ' + s + ' value: ' + res.getHeader(s));
}
}
return headers;
}
public static String get(HTTPResponse res, String headerkey) {
//get the list of header names (keys)
string[] headerkeys = res.getHeaderKeys();
// system.debug(headerkeys);
//iterate through they keys, and return value of key when found
for(string s : headerkeys){
if (s == headerkey) {
return res.getHeader(s);
system.debug('header: ' + s + ' value: ' + res.getHeader(s));
}
}
return null;
}
}