Skip to content

Commit 5d3cd58

Browse files
authored
Merge pull request #5 from Red5/feature/supported-headers-update
Feature/supported headers update
2 parents d7c6eb2 + 94d060f commit 5d3cd58

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<artifactId>websocket</artifactId>
1010
<packaging>jar</packaging>
1111
<name>websocket</name>
12-
<version>1.9</version>
12+
<version>1.10</version>
1313
<description>Red5 WebSocket plugin</description>
1414
<url>https://github.com/Red5/red5-websocket</url>
1515
<organization>

src/main/java/org/red5/net/websocket/Constants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public class Constants {
4646
public final static String HTTP_HEADER_ORIGIN = "Origin";
4747

4848
public final static String HTTP_HEADER_USERAGENT = "User-Agent";
49+
50+
public final static String WS_HEADER_FORWARDED = "X-Forwarded-For";
51+
52+
public final static String WS_HEADER_REAL_IP = "X-Real-IP";
53+
54+
public final static String WS_HEADER_GENERIC_PREFIX = "X-";
4955

5056
public static final String URI_QS_PARAMETERS = "querystring-parameters";
5157

src/main/java/org/red5/net/websocket/codec/WebSocketDecoder.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public void operationComplete(IoFuture future) {
291291
});
292292
throw new WebSocketException("Handshake failed, missing plugin");
293293
}
294-
} else if (request[i].contains(Constants.WS_HEADER_KEY)) {
294+
}else if (request[i].contains(Constants.WS_HEADER_KEY)) {
295295
map.put(Constants.WS_HEADER_KEY, extractHeaderValue(request[i]));
296296
} else if (request[i].contains(Constants.WS_HEADER_VERSION)) {
297297
map.put(Constants.WS_HEADER_VERSION, extractHeaderValue(request[i]));
@@ -307,10 +307,26 @@ public void operationComplete(IoFuture future) {
307307
conn.setOrigin(extractHeaderValue(request[i]));
308308
} else if (request[i].contains(Constants.HTTP_HEADER_USERAGENT)) {
309309
map.put(Constants.HTTP_HEADER_USERAGENT, extractHeaderValue(request[i]));
310+
}else if (request[i].startsWith(Constants.WS_HEADER_GENERIC_PREFIX)) {
311+
map.put(getHeaderName(request[i]), extractHeaderValue(request[i]));
310312
}
311313
}
312314
return map;
313315
}
316+
317+
318+
319+
/**
320+
* Returns the trimmed header name.
321+
*
322+
* @param requestHeader
323+
* @return value
324+
*/
325+
private String getHeaderName(String requestHeader){
326+
return requestHeader.substring(0, requestHeader.indexOf(':')).trim();
327+
}
328+
329+
314330

315331
/**
316332
* Returns the trimmed header value.

0 commit comments

Comments
 (0)