|
55 | 55 | import org.openqa.selenium.remote.http.CloseMessage; |
56 | 56 | import org.openqa.selenium.remote.http.HttpClient; |
57 | 57 | import org.openqa.selenium.remote.http.HttpClientName; |
| 58 | +import org.openqa.selenium.remote.http.HttpMethod; |
58 | 59 | import org.openqa.selenium.remote.http.HttpRequest; |
59 | 60 | import org.openqa.selenium.remote.http.HttpResponse; |
60 | 61 | import org.openqa.selenium.remote.http.Message; |
@@ -357,14 +358,15 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException { |
357 | 358 |
|
358 | 359 | BodyHandler<byte[]> byteHandler = BodyHandlers.ofByteArray(); |
359 | 360 | try { |
| 361 | + HttpMethod method = req.getMethod(); |
360 | 362 | URI rawUri = messages.getRawUri(req); |
361 | 363 |
|
362 | 364 | // We need a custom handling of redirects to: |
363 | 365 | // - increase the maximum number of retries to 100 |
364 | 366 | // - avoid a downgrade of POST requests, see the javadoc of j.n.h.HttpClient.Redirect |
365 | 367 | // - not run into https://bugs.openjdk.org/browse/JDK-8304701 |
366 | 368 | for (int i = 0; i < 100; i++) { |
367 | | - java.net.http.HttpRequest request = messages.createRequest(req, rawUri); |
| 369 | + java.net.http.HttpRequest request = messages.createRequest(req, method, rawUri); |
368 | 370 | java.net.http.HttpResponse<byte[]> response; |
369 | 371 |
|
370 | 372 | // use sendAsync to not run into https://bugs.openjdk.org/browse/JDK-8258397 |
@@ -393,9 +395,11 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException { |
393 | 395 | } |
394 | 396 |
|
395 | 397 | switch (response.statusCode()) { |
| 398 | + case 303: |
| 399 | + method = HttpMethod.GET; |
| 400 | + // fall-through |
396 | 401 | case 301: |
397 | 402 | case 302: |
398 | | - case 303: |
399 | 403 | case 307: |
400 | 404 | case 308: |
401 | 405 | URI location = |
|
0 commit comments