15
15
// specific language governing permissions and limitations
16
16
// under the License.
17
17
18
- package org .openqa .selenium .devtools .v99 ;
18
+ package org .openqa .selenium .devtools .v102 ;
19
19
20
20
import com .google .common .collect .ImmutableList ;
21
21
import com .google .common .io .ByteStreams ;
25
25
import org .openqa .selenium .devtools .DevToolsException ;
26
26
import org .openqa .selenium .devtools .Event ;
27
27
import org .openqa .selenium .devtools .idealized .Network ;
28
- import org .openqa .selenium .devtools .v99 .fetch .Fetch ;
29
- import org .openqa .selenium .devtools .v99 .fetch .model .AuthChallengeResponse ;
30
- import org .openqa .selenium .devtools .v99 .fetch .model .AuthRequired ;
31
- import org .openqa .selenium .devtools .v99 .fetch .model .HeaderEntry ;
32
- import org .openqa .selenium .devtools .v99 .fetch .model .RequestPattern ;
33
- import org .openqa .selenium .devtools .v99 .fetch .model .RequestPaused ;
34
- import org .openqa .selenium .devtools .v99 .fetch .model .RequestStage ;
35
- import org .openqa .selenium .devtools .v99 .network .model .Request ;
28
+ import org .openqa .selenium .devtools .v102 .fetch .Fetch ;
29
+ import org .openqa .selenium .devtools .v102 .fetch .model .AuthChallengeResponse ;
30
+ import org .openqa .selenium .devtools .v102 .fetch .model .AuthRequired ;
31
+ import org .openqa .selenium .devtools .v102 .fetch .model .HeaderEntry ;
32
+ import org .openqa .selenium .devtools .v102 .fetch .model .RequestPattern ;
33
+ import org .openqa .selenium .devtools .v102 .fetch .model .RequestPaused ;
34
+ import org .openqa .selenium .devtools .v102 .fetch .model .RequestStage ;
35
+ import org .openqa .selenium .devtools .v102 .network .model .Request ;
36
36
import org .openqa .selenium .internal .Either ;
37
37
import org .openqa .selenium .remote .http .HttpRequest ;
38
38
import org .openqa .selenium .remote .http .HttpResponse ;
50
50
51
51
import static java .net .HttpURLConnection .HTTP_OK ;
52
52
53
- public class V99Network extends Network <AuthRequired , RequestPaused > {
53
+ public class V102Network extends Network <AuthRequired , RequestPaused > {
54
54
55
- private static final Logger LOG = Logger .getLogger (V99Network .class .getName ());
55
+ private static final Logger LOG = Logger .getLogger (V102Network .class .getName ());
56
56
57
- public V99Network (DevTools devTools ) {
57
+ public V102Network (DevTools devTools ) {
58
58
super (devTools );
59
59
}
60
60
61
61
@ Override
62
62
protected Command <Void > setUserAgentOverride (UserAgent userAgent ) {
63
- return org .openqa .selenium .devtools .v99 .network .Network .setUserAgentOverride (
63
+ return org .openqa .selenium .devtools .v102 .network .Network .setUserAgentOverride (
64
64
userAgent .userAgent (), userAgent .acceptLanguage (), userAgent .platform (), Optional .empty ());
65
65
}
66
66
67
67
@ Override
68
68
protected Command <Void > enableNetworkCaching () {
69
- return org .openqa .selenium .devtools .v99 .network .Network .setCacheDisabled (false );
69
+ return org .openqa .selenium .devtools .v102 .network .Network .setCacheDisabled (false );
70
70
}
71
71
72
72
@ Override
73
73
protected Command <Void > disableNetworkCaching () {
74
- return org .openqa .selenium .devtools .v99 .network .Network .setCacheDisabled (true );
74
+ return org .openqa .selenium .devtools .v102 .network .Network .setCacheDisabled (true );
75
75
}
76
76
77
77
@ Override
78
78
protected Command <Void > enableFetchForAllPatterns () {
79
79
return Fetch .enable (
80
80
Optional .of (ImmutableList .of (
81
81
new RequestPattern (Optional .of ("*" ), Optional .empty (), Optional .of (RequestStage .REQUEST )),
82
- new RequestPattern (Optional .of ("*" ), Optional .empty (), Optional .of (RequestStage .RESPONSE )))),
82
+ new RequestPattern (Optional .of ("*" ), Optional .empty (),
83
+ Optional .of (RequestStage .RESPONSE )))),
83
84
Optional .of (true ));
84
85
}
85
86
@@ -99,7 +100,8 @@ protected String getUriFrom(AuthRequired authRequired) {
99
100
}
100
101
101
102
@ Override
102
- protected Command <Void > continueWithAuth (AuthRequired authRequired , UsernameAndPassword credentials ) {
103
+ protected Command <Void > continueWithAuth (AuthRequired authRequired ,
104
+ UsernameAndPassword credentials ) {
103
105
return Fetch .continueWithAuth (
104
106
authRequired .getRequestId (),
105
107
new AuthChallengeResponse (
@@ -112,7 +114,8 @@ protected Command<Void> continueWithAuth(AuthRequired authRequired, UsernameAndP
112
114
protected Command <Void > cancelAuth (AuthRequired authRequired ) {
113
115
return Fetch .continueWithAuth (
114
116
authRequired .getRequestId (),
115
- new AuthChallengeResponse (AuthChallengeResponse .Response .CANCELAUTH , Optional .empty (), Optional .empty ()));
117
+ new AuthChallengeResponse (AuthChallengeResponse .Response .CANCELAUTH , Optional .empty (),
118
+ Optional .empty ()));
116
119
}
117
120
118
121
@ Override
@@ -122,14 +125,18 @@ public Event<RequestPaused> requestPausedEvent() {
122
125
123
126
@ Override
124
127
public Either <HttpRequest , HttpResponse > createSeMessages (RequestPaused pausedReq ) {
125
- if (pausedReq .getResponseStatusCode ().isPresent () || pausedReq .getResponseErrorReason ().isPresent ()) {
128
+ if (pausedReq .getResponseStatusCode ().isPresent () || pausedReq .getResponseErrorReason ()
129
+ .isPresent ()) {
126
130
String body ;
127
131
boolean bodyIsBase64Encoded ;
128
132
129
133
try {
130
- Fetch .GetResponseBodyResponse base64Body = devTools .send (Fetch .getResponseBody (pausedReq .getRequestId ()));
134
+ Fetch .GetResponseBodyResponse
135
+ base64Body =
136
+ devTools .send (Fetch .getResponseBody (pausedReq .getRequestId ()));
131
137
body = base64Body .getBody ();
132
- bodyIsBase64Encoded = base64Body .getBase64Encoded () != null && base64Body .getBase64Encoded ();
138
+ bodyIsBase64Encoded =
139
+ base64Body .getBase64Encoded () != null && base64Body .getBase64Encoded ();
133
140
} catch (DevToolsException e ) {
134
141
// Redirects don't seem to have bodies
135
142
int code = pausedReq .getResponseStatusCode ().orElse (HTTP_OK );
@@ -143,7 +150,9 @@ public Either<HttpRequest, HttpResponse> createSeMessages(RequestPaused pausedRe
143
150
144
151
List <Map .Entry <String , String >> headers = new LinkedList <>();
145
152
pausedReq .getResponseHeaders ().ifPresent (resHeaders ->
146
- resHeaders .forEach (header -> headers .add (new AbstractMap .SimpleEntry <>(header .getName (), header .getValue ()))));
153
+ resHeaders .forEach (header -> headers .add (
154
+ new AbstractMap .SimpleEntry <>(header .getName (),
155
+ header .getValue ()))));
147
156
148
157
HttpResponse res = createHttpResponse (
149
158
pausedReq .getResponseStatusCode (),
@@ -191,7 +200,8 @@ protected Command<Void> continueRequest(RequestPaused pausedReq, HttpRequest req
191
200
}
192
201
193
202
List <HeaderEntry > headers = new LinkedList <>();
194
- req .getHeaderNames ().forEach (name -> req .getHeaders (name ).forEach (value -> headers .add (new HeaderEntry (name , value ))));
203
+ req .getHeaderNames ().forEach (
204
+ name -> req .getHeaders (name ).forEach (value -> headers .add (new HeaderEntry (name , value ))));
195
205
196
206
return Fetch .continueRequest (
197
207
pausedReq .getRequestId (),
@@ -205,7 +215,8 @@ protected Command<Void> continueRequest(RequestPaused pausedReq, HttpRequest req
205
215
@ Override
206
216
protected Command <Void > fulfillRequest (RequestPaused pausedReq , HttpResponse res ) {
207
217
List <HeaderEntry > headers = new LinkedList <>();
208
- res .getHeaderNames ().forEach (name -> res .getHeaders (name ).forEach (value -> headers .add (new HeaderEntry (name , value ))));
218
+ res .getHeaderNames ().forEach (
219
+ name -> res .getHeaders (name ).forEach (value -> headers .add (new HeaderEntry (name , value ))));
209
220
210
221
ByteArrayOutputStream bos = new ByteArrayOutputStream ();
211
222
try (InputStream is = res .getContent ().get ()) {
0 commit comments