|
17 | 17 |
|
18 | 18 | package org.openqa.selenium.remote.server;
|
19 | 19 |
|
20 |
| -//import static com.google.common.net.MediaType.JAVASCRIPT_UTF_8; |
21 |
| - |
22 | 20 | import static com.google.common.net.MediaType.JSON_UTF_8;
|
23 | 21 | import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
|
24 | 22 | import static java.net.HttpURLConnection.HTTP_OK;
|
25 | 23 | import static java.nio.charset.StandardCharsets.UTF_8;
|
26 | 24 | import static org.openqa.selenium.remote.ErrorCodes.NO_SUCH_SESSION;
|
| 25 | +import static org.openqa.selenium.remote.ErrorCodes.SUCCESS; |
27 | 26 | import static org.openqa.selenium.remote.ErrorCodes.UNKNOWN_COMMAND;
|
28 | 27 |
|
29 | 28 | import com.google.common.base.Splitter;
|
30 | 29 | import com.google.common.base.Strings;
|
31 | 30 | import com.google.common.collect.ImmutableMap;
|
32 | 31 | import com.google.gson.GsonBuilder;
|
33 | 32 |
|
| 33 | +import org.openqa.selenium.internal.BuildInfo; |
34 | 34 | import org.openqa.selenium.remote.SessionId;
|
35 | 35 | import org.openqa.selenium.remote.http.HttpRequest;
|
36 | 36 | import org.openqa.selenium.remote.http.HttpResponse;
|
@@ -146,11 +146,36 @@ private static class StatusHandler implements CommandHandler {
|
146 | 146 |
|
147 | 147 | @Override
|
148 | 148 | 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 | + |
149 | 174 | // 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); |
154 | 179 |
|
155 | 180 | resp.setStatus(HTTP_OK);
|
156 | 181 | resp.setHeader("Content-Type", JSON_UTF_8.toString());
|
|
0 commit comments