diff --git a/changes.md b/changes.md index e15298cdc2..12f7e31e66 100644 --- a/changes.md +++ b/changes.md @@ -74,6 +74,7 @@ Changes log communication-error response callback. - HTTP/2 and HTTP/3 requests advertise `te: trailers`; stream header names are normalized to lowercase at the HTTP boundary. + - Added the `Protocol.STDIO` pseudo-protocol constant for standard input/output connectors. - Bugs fixed - Slf4j bridge reports wrong line number and caller class in log4j. Issue #233. - When GET is an allowed method of a server resource, HEAD is now also listed (e.g. in the Allow header of a 405 response). Issue #266. diff --git a/org.restlet/src/main/java/org/restlet/data/Protocol.java b/org.restlet/src/main/java/org/restlet/data/Protocol.java index 08a9200212..271e50d5f7 100644 --- a/org.restlet/src/main/java/org/restlet/data/Protocol.java +++ b/org.restlet/src/main/java/org/restlet/data/Protocol.java @@ -91,6 +91,10 @@ public final class Protocol { public static final Protocol RIAP = new Protocol("riap", "RIAP", "Restlet Internal Access Protocol", UNKNOWN_PORT, true); + /** Standard Input/Output pseudo-protocol. */ + public static final Protocol STDIO = + new Protocol("stdio", "STDIO", "Standard Input/Output Streams", UNKNOWN_PORT); + /** * ZIP is a special scheme to access to representations inside Zip archive files. Example URI: * "zip:file:///tmp/test.zip!/test.txt". @@ -127,6 +131,8 @@ public static Protocol valueOf(String name) { result = JDBC; } else if (name.equalsIgnoreCase(RIAP.getSchemeName())) { result = RIAP; + } else if (name.equalsIgnoreCase(STDIO.getSchemeName())) { + result = STDIO; } else if (name.equalsIgnoreCase(ZIP.getSchemeName())) { result = ZIP; } else { diff --git a/org.restlet/src/test/java/org/restlet/data/ProtocolTestCase.java b/org.restlet/src/test/java/org/restlet/data/ProtocolTestCase.java index ccfe0691f3..3eec5fc7cf 100644 --- a/org.restlet/src/test/java/org/restlet/data/ProtocolTestCase.java +++ b/org.restlet/src/test/java/org/restlet/data/ProtocolTestCase.java @@ -76,9 +76,18 @@ void valueOf_knownScheme_returnsSharedConstant() { assertSame(Protocol.JAR, Protocol.valueOf("jar")); assertSame(Protocol.JDBC, Protocol.valueOf("jdbc")); assertSame(Protocol.RIAP, Protocol.valueOf("riap")); + assertSame(Protocol.STDIO, Protocol.valueOf("stdio")); assertSame(Protocol.ZIP, Protocol.valueOf("zip")); } + @Test + void stdio_isAnUnknownPortPseudoProtocol() { + assertEquals("stdio", Protocol.STDIO.getSchemeName()); + assertEquals("STDIO", Protocol.STDIO.getName()); + assertEquals(Protocol.UNKNOWN_PORT, Protocol.STDIO.getDefaultPort()); + assertFalse(Protocol.STDIO.isConfidential()); + } + @Test void valueOf_unknownScheme_createsNewProtocol() { Protocol protocol = Protocol.valueOf("custom");