Skip to content

Commit e30eb11

Browse files
TOTOROYangmarci4
authored andcommitted
add host param base Draft_6455 (TooTallNate#535)
* some websocket server would check the handshake request origin.So the request head need origin value。 For example the webrtc candidate server. url:wss://apprtc-ws.webrtc.org:443/ws * add host param base Draft_6455 * rename and add description
1 parent 0d09b78 commit e30eb11

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.java_websocket.drafts;
2+
3+
import org.java_websocket.handshake.*;
4+
5+
/**
6+
* Description:
7+
* Base on Draft_6455
8+
* You can use this Draft to connect the WebRTC Candidate server(WebSocket)
9+
* The official Candidate server run on go programming language
10+
* I found The ws/wss HandShake request must have origin param
11+
* If not it will return http code 403
12+
* If you get http code 403 and you ws/wss server run on go, you can try this Draft
13+
* Author:totoroYang 2017/8/8.
14+
*/
15+
16+
public class Draft_6455_WebRTC extends Draft_6455 {
17+
18+
@Override
19+
public ClientHandshakeBuilder postProcessHandshakeRequestAsClient(ClientHandshakeBuilder request) {
20+
super.postProcessHandshakeRequestAsClient(request);
21+
request.put("origin", request.getFieldValue("host"));
22+
return request;
23+
}
24+
25+
@Override
26+
public Draft copyInstance() {
27+
return new Draft_6455_WebRTC();
28+
}
29+
}

0 commit comments

Comments
 (0)