mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-02 09:56:53 +00:00
Add opt-in timeouts to provisioning websocket
This commit is contained in:
1 parent
6460327372
commit
68f27be7cd
10 files changed
+310
-37
No files matched your search
@@ -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