Skip to content

Commit

Permalink
[grid]: dialect not needed in create session response
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Mar 19, 2019
1 parent 3e4b3db commit a91ac58
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,16 @@

public class CreateSessionResponse {

private final Dialect dialect;
private final Session session;
private final byte[] downstreamEncodedResponse;

public CreateSessionResponse(
Dialect dialect,
Session session,
byte[] downstreamEncodedResponse) {
this.dialect = Objects.requireNonNull(dialect);
this.session = Objects.requireNonNull(session);
this.downstreamEncodedResponse = Objects.requireNonNull(downstreamEncodedResponse);
}

public Dialect getDialect() {
return dialect;
}

public Session getSession() {
return session;
}
Expand All @@ -55,23 +48,17 @@ public byte[] getDownstreamEncodedResponse() {

private Map<String, Object> toJson() {
return ImmutableMap.of(
"dialect", dialect,
"downstreamEncodedResponse", Base64.getEncoder().encodeToString(downstreamEncodedResponse),
"session", session);
}

private static CreateSessionResponse fromJson(JsonInput input) {
Dialect dialect = null;
Session session = null;
byte[] downstreamResponse = null;

input.beginObject();
while (input.hasNext()) {
switch (input.nextName()) {
case "dialect":
dialect = input.read(Dialect.class);
break;

case "downstreamEncodedResponse":
downstreamResponse = Base64.getDecoder().decode(input.nextString());
break;
Expand All @@ -87,6 +74,6 @@ private static CreateSessionResponse fromJson(JsonInput input) {
}
input.endObject();

return new CreateSessionResponse(dialect, session, downstreamResponse);
return new CreateSessionResponse(session, downstreamResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ public Optional<CreateSessionResponse> newSession(CreateSessionRequest sessionRe
// The session we return has to look like it came from the node, since we might be dealing
// with a webdriver implementation that only accepts connections from localhost
return Optional.of(new CreateSessionResponse(
dialect,
createExternalSession(session, externalUri),
resultEncoder.apply(session)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.openqa.selenium.grid.web.CombinedHandler;
import org.openqa.selenium.grid.web.RoutableHttpClientFactory;
import org.openqa.selenium.json.Json;
import org.openqa.selenium.remote.Dialect;
import org.openqa.selenium.remote.SessionId;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.http.HttpRequest;
Expand Down Expand Up @@ -216,7 +215,6 @@ public Optional<CreateSessionResponse> newSession(CreateSessionRequest sessionRe
Session session = factory.apply(sessionRequest.getCapabilities());
running = session;
return Optional.of(new CreateSessionResponse(
Dialect.W3C,
session,
new Json().toJson(ImmutableMap.of(
"value", ImmutableMap.of(
Expand Down

0 comments on commit a91ac58

Please sign in to comment.