我有一個客戶端使用代理來控制客戶端的Internet連接。 如何將Websocket標頭中的用戶/身份驗證值傳遞給代理。發送代理服務器驗證通過Websocket到代理服務器
我正在使用標準的Netty植入。
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
final String funcName = "messageReceived - ";
try {
Object msg = e.getMessage();
logger.debug(funcName + msg + "class" + msg.getClass().getName());
ThreadParams.setLoggingEnabled(true);
if (msg instanceof HttpRequest) {
handleHttpShakeHand(ctx, (HttpRequest) msg);
// TaUtils.sleep(5000);
} else if (msg instanceof WebSocketFrame) {
handleWebSocketFrame(ctx, (WebSocketFrame) msg);
}
} catch (Throwable t) {
logger.error(funcName + "error: ", t);
}
}
private void handleHttpShakeHand(ChannelHandlerContext ctx, HttpRequest req) throws Exception {
// Handshake
WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(
this.getWebSocketLocation(req), null, false);
this.handshaker = wsFactory.newHandshaker(req);
if (this.handshaker == null) {
wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.getChannel());
} else {
this.handshaker.performOpeningHandshake(ctx.getChannel(), req);
}
return;
}
在我使用Chrome的對象打開與服務器的WebSocket的客戶端。
ws = new WebSocket(localStorage["wsPath"]);
ws.onclose = onClose;
ws.onopen = onOpen;
ws.onerror = onError;
塔米爾
這是令人興奮的,我們正在做什麼,但它不工作。我怎麼能確定服務器端的Shakehand真正返回Http頭中的Auth數據? – 2012-07-20 06:31:43