Skip to content

Commit 9488e91

Browse files
committed
Flesh out the new status endpoint implementation
1 parent 93abdbe commit 9488e91

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

java/server/src/org/openqa/selenium/remote/server/AllHandlers.java

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717

1818
package org.openqa.selenium.remote.server;
1919

20-
//import static com.google.common.net.MediaType.JAVASCRIPT_UTF_8;
21-
2220
import static com.google.common.net.MediaType.JSON_UTF_8;
2321
import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
2422
import static java.net.HttpURLConnection.HTTP_OK;
2523
import static java.nio.charset.StandardCharsets.UTF_8;
2624
import static org.openqa.selenium.remote.ErrorCodes.NO_SUCH_SESSION;
25+
import static org.openqa.selenium.remote.ErrorCodes.SUCCESS;
2726
import static org.openqa.selenium.remote.ErrorCodes.UNKNOWN_COMMAND;
2827

2928
import com.google.common.base.Splitter;
3029
import com.google.common.base.Strings;
3130
import com.google.common.collect.ImmutableMap;
3231
import com.google.gson.GsonBuilder;
3332

33+
import org.openqa.selenium.internal.BuildInfo;
3434
import org.openqa.selenium.remote.SessionId;
3535
import org.openqa.selenium.remote.http.HttpRequest;
3636
import org.openqa.selenium.remote.http.HttpResponse;
@@ -146,11 +146,36 @@ private static class StatusHandler implements CommandHandler {
146146

147147
@Override
148148
public void execute(HttpRequest req, HttpResponse resp) throws IOException {
149+
ImmutableMap.Builder<String, Object> value = ImmutableMap.builder();
150+
151+
// W3C spec
152+
value.put("ready", true);
153+
value.put("message", "Server is running");
154+
155+
// And now more information
156+
BuildInfo buildInfo = new BuildInfo();
157+
value.put("build", ImmutableMap.of(
158+
// We need to fix the BuildInfo to properly fill out these values.
159+
// "revision", buildInfo.getBuildRevision(),
160+
// "time", buildInfo.getBuildTime(),
161+
"version", buildInfo.getReleaseLabel()));
162+
163+
value.put("os", ImmutableMap.of(
164+
"arch", System.getProperty("os.arch"),
165+
"name", System.getProperty("os.name"),
166+
"version", System.getProperty("os.version")));
167+
168+
value.put("java", ImmutableMap.of("version", System.getProperty("java.version")));
169+
170+
Map<String, Object> payloadObj = ImmutableMap.of(
171+
"status", SUCCESS,
172+
"value", value.build());
173+
149174
// Write out a minimal W3C status response.
150-
byte[] payload = new GsonBuilder().create().toJson(ImmutableMap.of(
151-
"ready", true,
152-
"message", "Server is running"
153-
)).getBytes(UTF_8);
175+
byte[] payload = new GsonBuilder()
176+
.serializeNulls()
177+
.create()
178+
.toJson(payloadObj).getBytes(UTF_8);
154179

155180
resp.setStatus(HTTP_OK);
156181
resp.setHeader("Content-Type", JSON_UTF_8.toString());

0 commit comments

Comments
 (0)