Skip to content

Commit 13d0bbe

Browse files
jlouvelCopilot
andcommitted
feat: add stdio protocol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Jerome Louvel <374450+jlouvel@users.noreply.github.com>
1 parent f4121a8 commit 13d0bbe

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎changes.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Changes log
7474
communication-error response callback.
7575
- HTTP/2 and HTTP/3 requests advertise `te: trailers`; stream header names are normalized
7676
to lowercase at the HTTP boundary.
77+
- Added the `Protocol.STDIO` pseudo-protocol constant for standard input/output connectors.
7778
- Bugs fixed
7879
- Slf4j bridge reports wrong line number and caller class in log4j. Issue #233.
7980
- 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.

‎org.restlet/src/main/java/org/restlet/data/Protocol.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ public final class Protocol {
9191
public static final Protocol RIAP =
9292
new Protocol("riap", "RIAP", "Restlet Internal Access Protocol", UNKNOWN_PORT, true);
9393

94+
/** Standard Input/Output pseudo-protocol. */
95+
public static final Protocol STDIO =
96+
new Protocol("stdio", "STDIO", "Standard Input/Output Streams", UNKNOWN_PORT);
97+
9498
/**
9599
* ZIP is a special scheme to access to representations inside Zip archive files. Example URI:
96100
* "zip:file:///tmp/test.zip!/test.txt".
@@ -127,6 +131,8 @@ public static Protocol valueOf(String name) {
127131
result = JDBC;
128132
} else if (name.equalsIgnoreCase(RIAP.getSchemeName())) {
129133
result = RIAP;
134+
} else if (name.equalsIgnoreCase(STDIO.getSchemeName())) {
135+
result = STDIO;
130136
} else if (name.equalsIgnoreCase(ZIP.getSchemeName())) {
131137
result = ZIP;
132138
} else {

‎org.restlet/src/test/java/org/restlet/data/ProtocolTestCase.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,18 @@ void valueOf_knownScheme_returnsSharedConstant() {
7676
assertSame(Protocol.JAR, Protocol.valueOf("jar"));
7777
assertSame(Protocol.JDBC, Protocol.valueOf("jdbc"));
7878
assertSame(Protocol.RIAP, Protocol.valueOf("riap"));
79+
assertSame(Protocol.STDIO, Protocol.valueOf("stdio"));
7980
assertSame(Protocol.ZIP, Protocol.valueOf("zip"));
8081
}
8182

83+
@Test
84+
void stdio_isAnUnknownPortPseudoProtocol() {
85+
assertEquals("stdio", Protocol.STDIO.getSchemeName());
86+
assertEquals("STDIO", Protocol.STDIO.getName());
87+
assertEquals(Protocol.UNKNOWN_PORT, Protocol.STDIO.getDefaultPort());
88+
assertFalse(Protocol.STDIO.isConfidential());
89+
}
90+
8291
@Test
8392
void valueOf_unknownScheme_createsNewProtocol() {
8493
Protocol protocol = Protocol.valueOf("custom");

0 commit comments

Comments
 (0)