1
1
/*
2
- * Copyright 2002-2018 the original author or authors.
2
+ * Copyright 2002-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ class WiretapConnector implements ClientHttpConnector {
53
53
54
54
private final ClientHttpConnector delegate ;
55
55
56
- private final Map <String , Info > exchanges = new ConcurrentHashMap <>();
56
+ private final Map <String , ClientExchangeInfo > exchanges = new ConcurrentHashMap <>();
57
57
58
58
59
59
WiretapConnector (ClientHttpConnector delegate ) {
@@ -79,43 +79,47 @@ public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
79
79
String requestId = wrappedRequest .getHeaders ().getFirst (header );
80
80
Assert .state (requestId != null , () -> "No \" " + header + "\" header" );
81
81
WiretapClientHttpResponse wrappedResponse = new WiretapClientHttpResponse (response );
82
- this .exchanges .put (requestId , new Info (wrappedRequest , wrappedResponse ));
82
+ this .exchanges .put (requestId , new ClientExchangeInfo (wrappedRequest , wrappedResponse ));
83
83
return wrappedResponse ;
84
84
});
85
85
}
86
86
87
87
/**
88
- * Retrieve the {@link Info } for the given "request-id" header value.
88
+ * Create the {@link ExchangeResult } for the given "request-id" header value.
89
89
*/
90
- public Info claimRequest (String requestId ) {
91
- Info info = this .exchanges .remove (requestId );
90
+ ExchangeResult getExchangeResult (String requestId , @ Nullable String uriTemplate , Duration timeout ) {
91
+ ClientExchangeInfo info = this .exchanges .remove (requestId );
92
92
Assert .state (info != null , () -> {
93
93
String header = WebTestClient .WEBTESTCLIENT_REQUEST_ID ;
94
94
return "No match for " + header + "=" + requestId ;
95
95
});
96
- return info ;
96
+ return new ExchangeResult (info .getRequest (), info .getResponse (),
97
+ info .getRequest ().getRecorder ().getContent (),
98
+ info .getResponse ().getRecorder ().getContent (),
99
+ timeout , uriTemplate );
97
100
}
98
101
99
102
100
103
/**
101
104
* Holder for {@link WiretapClientHttpRequest} and {@link WiretapClientHttpResponse}.
102
105
*/
103
- class Info {
106
+ private static class ClientExchangeInfo {
104
107
105
108
private final WiretapClientHttpRequest request ;
106
109
107
110
private final WiretapClientHttpResponse response ;
108
111
109
-
110
- public Info (WiretapClientHttpRequest request , WiretapClientHttpResponse response ) {
112
+ public ClientExchangeInfo (WiretapClientHttpRequest request , WiretapClientHttpResponse response ) {
111
113
this .request = request ;
112
114
this .response = response ;
113
115
}
114
116
117
+ public WiretapClientHttpRequest getRequest () {
118
+ return this .request ;
119
+ }
115
120
116
- public ExchangeResult createExchangeResult (Duration timeout , @ Nullable String uriTemplate ) {
117
- return new ExchangeResult (this .request , this .response , this .request .getRecorder ().getContent (),
118
- this .response .getRecorder ().getContent (), timeout , uriTemplate );
121
+ public WiretapClientHttpResponse getResponse () {
122
+ return this .response ;
119
123
}
120
124
}
121
125
0 commit comments