Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
JHttpResponse.java
Go to the documentation of this file.
1 package com.griddynamics.jagger.invoker.v2;
2 
3 import static java.util.stream.Collectors.toMap;
4 
5 import org.springframework.http.HttpHeaders;
6 import org.springframework.http.HttpStatus;
7 
8 import java.io.Serializable;
9 import java.util.Map;
10 
20 public class JHttpResponse<T> implements Serializable {
21 
22  private HttpStatus status;
23  private T body;
24  private HttpHeaders headers;
25 
26  public JHttpResponse(HttpStatus status, T body, HttpHeaders headers) {
27  this.status = status;
28  this.body = body;
29  this.headers = headers;
30  }
31 
32  public HttpStatus getStatus() {
33  return status;
34  }
35 
36  public T getBody() {
37  return body;
38  }
39 
40  public HttpHeaders getHeaders() {
41  return headers;
42  }
43 
44  public Map<String, String> getCookies() {
45  return headers.get("Cookie").stream()
46  .map(cookieStr -> cookieStr.split("="))
47  .collect(toMap(cookieArr -> cookieArr[0], cookieArr -> cookieArr[1]));
48  }
49 
50  @Override
51  public String toString() {
52  return "JHttpResponse{" +
53  "status=" + status +
54  ", body=" + body +
55  ", headers=" + headers +
56  '}';
57  }
58 }