Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ Changes log
the connector for synchronous calls, without leaking credentials to other origins.
- Removed `JettyServerHelper`, `JettyServerCall`, `JettyClientCall`, `JettyHandler`,
`RestletSslContextFactoryClient` and `RestletSslContextFactoryServer`.
- Removed the `org.restlet.engine.adapter` package (`Adapter`, `Call`, `ClientAdapter`,
`ClientCall`, `HttpClientHelper`, `HttpRequest`, `HttpResponse`, `HttpServerHelper`,
`ServerAdapter`, `ServerCall`) and the "adapter" connector parameter. The Netty
connectors now map Netty messages directly to Restlet requests and responses, and
`NettyServerHelper` and `NettyClientHelper` extend `ServerHelper` and `ClientHelper`.
Custom HTTP connectors should extend those classes. Request headers remain available
with `Message.getHeaders()`.
- `MultiPartRepresentation` no longer exposes Jetty types: parts are instances of the new
`MultiPartRepresentation.Part` class (name, file name, headers, content
representation), parsing takes an optional storage directory instead of a Jetty
Expand All @@ -54,6 +61,11 @@ Changes log
- Removed the `Protocol.WAR` constant ("war" scheme, Web Archive Access Protocol), a
leftover of the Servlet mode, which is no longer supported. `Protocol.valueOf("war")`
now returns a new, unknown protocol. Use CLAP or FILE references instead.
- Enhancements
- Added `Response.getProtocol()` and `setProtocol()`: the protocol, with its version,
used by the server to reply (for example HTTP/1.1, HTTP/2.0 or HTTP/3.0), set by the HTTP
client connector. When unknown, the protocol of the request is returned.
`Response.toString()` now shows it.
- 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.
Expand Down
1 change: 0 additions & 1 deletion org.restlet/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
exports org.restlet;
exports org.restlet.data;
exports org.restlet.engine;
exports org.restlet.engine.adapter;
exports org.restlet.engine.application;
exports org.restlet.engine.component;
exports org.restlet.engine.connector;
Expand Down
29 changes: 28 additions & 1 deletion org.restlet/src/main/java/org/restlet/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.restlet.data.CookieSetting;
import org.restlet.data.Dimension;
import org.restlet.data.Method;
import org.restlet.data.Protocol;
import org.restlet.data.Reference;
import org.restlet.data.ServerInfo;
import org.restlet.data.Status;
Expand Down Expand Up @@ -135,6 +136,9 @@ public static void setCurrent(Response response) {
/** Indicates how long the service is expected to be unavailable to the requesting client. */
private volatile Date retryAfter;

/** The protocol, with its version, used by the server to reply. */
private volatile Protocol protocol;

/** The server-specific information. */
private volatile ServerInfo serverInfo;

Expand Down Expand Up @@ -162,6 +166,7 @@ public Response(Request request) {
this.locationRef = null;
this.proxyChallengeRequests = null;
this.request = request;
this.protocol = null;
this.retryAfter = null;
this.serverInfo = null;
this.status = Status.SUCCESS_OK;
Expand Down Expand Up @@ -476,6 +481,18 @@ public Date getRetryAfter() {
return retryAfter;
}

/**
* Returns the protocol, with its version, used by the server to reply, if known. For example,
* the HTTP client connector sets "HTTP/1.1", "HTTP/2.0" or "HTTP/3.0" (secure exchanges use the
* HTTPS protocol). When unknown, returns the protocol of the request.
*
* @return The protocol used by the server to reply.
*/
public Protocol getProtocol() {
Protocol result = this.protocol;
return (result == null && getRequest() != null) ? getRequest().getProtocol() : result;
}

/**
* Returns the server-specific information. Creates a new instance if no one has been set.
*
Expand Down Expand Up @@ -932,6 +949,15 @@ public void setRetryAfter(Date retryAfter) {
this.retryAfter = retryAfter;
}

/**
* Sets the protocol, with its version, used by the server to reply.
*
* @param protocol The protocol used by the server to reply.
*/
public void setProtocol(Protocol protocol) {
this.protocol = protocol;
}

/**
* Sets the server-specific information.
*
Expand Down Expand Up @@ -987,6 +1013,7 @@ public void setStatus(Status status, Throwable throwable, String message) {
* @return A synthesis of the response like an HTTP status line.
*/
public String toString() {
return ((getRequest() == null) ? "?" : getRequest().getProtocol()) + " - " + getStatus();
Protocol p = getProtocol();
return ((p == null) ? "?" : p) + " - " + getStatus();
}
}
51 changes: 0 additions & 51 deletions org.restlet/src/main/java/org/restlet/engine/adapter/Adapter.java

This file was deleted.

Loading
Loading