1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.esigate.http;
17
18 import java.net.URL;
19
20 import org.apache.http.ProtocolVersion;
21 import org.apache.http.RequestLine;
22 import org.apache.http.client.config.RequestConfig;
23 import org.apache.http.client.methods.Configurable;
24 import org.apache.http.message.BasicHttpEntityEnclosingRequest;
25 import org.apache.http.message.BasicRequestLine;
26 import org.esigate.UserContext;
27 import org.esigate.api.ContainerRequestContext;
28 import org.esigate.impl.DriverRequest;
29
30
31
32
33
34
35
36 public class OutgoingRequest extends BasicHttpEntityEnclosingRequest implements Configurable {
37
38 private RequestLine requestLine;
39 private final RequestConfig requestConfig;
40 private final OutgoingRequestContext context;
41 private final DriverRequest originalRequest;
42
43 public OutgoingRequest(String method, String uri, ProtocolVersion version, DriverRequest originalRequest,
44 RequestConfig requestConfig, OutgoingRequestContext context) {
45 super(method, uri, version);
46 requestLine = new BasicRequestLine(method, uri, version);
47 this.requestConfig = requestConfig;
48 this.context = context;
49 this.originalRequest = originalRequest;
50 }
51
52 public void setUri(String uri) {
53 requestLine = new BasicRequestLine(requestLine.getMethod(), uri, requestLine.getProtocolVersion());
54 }
55
56 @Override
57 public ProtocolVersion getProtocolVersion() {
58 return requestLine.getProtocolVersion();
59 }
60
61 @Override
62 public RequestLine getRequestLine() {
63 return requestLine;
64 }
65
66 @Override
67 public String toString() {
68 return requestLine.toString();
69 }
70
71 @Override
72 public RequestConfig getConfig() {
73 return requestConfig;
74 }
75
76 public OutgoingRequestContext getContext() {
77 return context;
78 }
79
80 public UserContext getUserContext() {
81 return originalRequest.getUserContext();
82 }
83
84 public ContainerRequestContext getContainerRequestContext() {
85 return originalRequest.getContext();
86 }
87
88 public URL getBaseUrl() {
89 return originalRequest.getBaseUrl();
90 }
91
92 public DriverRequest getOriginalRequest() {
93 return originalRequest;
94 }
95
96 }