A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/seleniumhq/selenium/commit/cd8b551d19bfdfb30ad669edd7705aa58cd90808 below:

Allow reading the response more than once · SeleniumHQ/selenium@cd8b551 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+6

-4

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+6

-4

lines changed Original file line number Diff line number Diff line change

@@ -33,6 +33,7 @@

33 33

import org.openqa.selenium.remote.http.TextMessage;

34 34

import org.openqa.selenium.remote.http.WebSocket;

35 35 36 +

import java.io.ByteArrayInputStream;

36 37

import java.io.IOException;

37 38

import java.io.InputStream;

38 39

import java.io.UncheckedIOException;

@@ -230,9 +231,9 @@ private URI getWebSocketUri(HttpRequest request) {

230 231

@Override

231 232

public HttpResponse execute(HttpRequest req) throws UncheckedIOException {

232 233

Objects.requireNonNull(req, "Request");

233 -

BodyHandler<InputStream> streamHandler = BodyHandlers.ofInputStream();

234 +

BodyHandler<byte[]> byteHandler = BodyHandlers.ofByteArray();

234 235

try {

235 -

return messages.createResponse(client.send(messages.createRequest(req), streamHandler));

236 +

return messages.createResponse(client.send(messages.createRequest(req), byteHandler));

236 237

} catch (HttpTimeoutException e) {

237 238

throw new TimeoutException(e);

238 239

} catch (IOException e) {

Original file line number Diff line number Diff line change

@@ -23,6 +23,7 @@

23 23

import org.openqa.selenium.remote.http.HttpRequest;

24 24

import org.openqa.selenium.remote.http.HttpResponse;

25 25 26 +

import java.io.ByteArrayInputStream;

26 27

import java.io.InputStream;

27 28

import java.net.URI;

28 29

import java.net.URLEncoder;

@@ -118,12 +119,12 @@ public URI getRawUri(HttpRequest req) {

118 119

return URI.create(rawUrl);

119 120

}

120 121 121 -

public HttpResponse createResponse(java.net.http.HttpResponse<InputStream> response) {

122 +

public HttpResponse createResponse(java.net.http.HttpResponse<byte[]> response) {

122 123

HttpResponse res = new HttpResponse();

123 124

res.setStatus(response.statusCode());

124 125

response.headers().map()

125 126

.forEach((name, values) -> values.stream().filter(Objects::nonNull).forEach(value -> res.addHeader(name, value)));

126 -

res.setContent(response::body);

127 +

res.setContent(() -> new ByteArrayInputStream(response.body()));

127 128 128 129

return res;

129 130

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4