mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-17 23:13:17 +01:00
Add opt-in timeouts to provisioning websocket
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
package org.whispersystems.websocket;
|
||||
|
||||
/**
|
||||
* Class containing constants and shared logic for handling stories.
|
||||
* <p>
|
||||
* In particular, it defines the way we interpret the X-Signal-Receive-Stories header
|
||||
* which is used by both WebSockets and by the REST API.
|
||||
*/
|
||||
public class Stories {
|
||||
public final static String X_SIGNAL_RECEIVE_STORIES = "X-Signal-Receive-Stories";
|
||||
|
||||
public static boolean parseReceiveStoriesHeader(String s) {
|
||||
return "true".equals(s);
|
||||
}
|
||||
}
|
||||
@@ -98,8 +98,12 @@ public class WebSocketClient {
|
||||
}
|
||||
|
||||
public boolean shouldDeliverStories() {
|
||||
String value = session.getUpgradeRequest().getHeader(Stories.X_SIGNAL_RECEIVE_STORIES);
|
||||
return Stories.parseReceiveStoriesHeader(value);
|
||||
String value = session.getUpgradeRequest().getHeader(WebsocketHeaders.X_SIGNAL_RECEIVE_STORIES);
|
||||
return WebsocketHeaders.parseReceiveStoriesHeader(value);
|
||||
}
|
||||
|
||||
public boolean supportsProvisioningSocketTimeouts() {
|
||||
return session.getUpgradeRequest().getHeader(WebsocketHeaders.X_SIGNAL_WEBSOCKET_TIMEOUT_HEADER) != null;
|
||||
}
|
||||
|
||||
private long generateRequestId() {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.whispersystems.websocket;
|
||||
|
||||
/**
|
||||
* Class containing constants and shared logic for headers used in websocket upgrade requests.
|
||||
*/
|
||||
public class WebsocketHeaders {
|
||||
public final static String X_SIGNAL_RECEIVE_STORIES = "X-Signal-Receive-Stories";
|
||||
public static final String X_SIGNAL_WEBSOCKET_TIMEOUT_HEADER = "X-Signal-Websocket-Timeout";
|
||||
|
||||
public static boolean parseReceiveStoriesHeader(String s) {
|
||||
return "true".equals(s);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user