418622 - WebSocket / When rejecting old WebSocket protocols, log client details
This commit is contained in:
parent
48fe92d939
commit
54c22d0aca
|
@ -479,7 +479,25 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
|
|||
WebSocketHandshake handshaker = handshakes.get(version);
|
||||
if (handshaker == null)
|
||||
{
|
||||
LOG.warn("Unsupported Websocket version: " + version);
|
||||
StringBuilder warn = new StringBuilder();
|
||||
warn.append("Client ").append(request.getRemoteAddress());
|
||||
warn.append(" (:").append(request.getRemotePort());
|
||||
warn.append(") User Agent: ");
|
||||
String ua = request.getHeader("User-Agent");
|
||||
if(ua == null) {
|
||||
warn.append("[unset] ");
|
||||
} else {
|
||||
warn.append('"').append(ua.replaceAll("<","<")).append("\" ");
|
||||
}
|
||||
warn.append("requested WebSocket version [").append(version);
|
||||
warn.append("], Jetty supports version");
|
||||
if (handshakes.size() > 1)
|
||||
{
|
||||
warn.append('s');
|
||||
}
|
||||
warn.append(": [").append(supportedVersions).append("]");
|
||||
LOG.warn(warn.toString());
|
||||
|
||||
// Per RFC 6455 - 4.4 - Supporting Multiple Versions of WebSocket Protocol
|
||||
// Using the examples as outlined
|
||||
response.setHeader("Sec-WebSocket-Version",supportedVersions);
|
||||
|
|
|
@ -18,16 +18,13 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.server.blockhead;
|
||||
|
||||
import static org.hamcrest.Matchers.anyOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
@ -44,8 +41,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
@ -618,6 +613,7 @@ public class BlockheadClient implements IncomingFrames, OutgoingFrames, Connecti
|
|||
req.append("GET ").append(getRequestPath()).append(" HTTP/1.1\r\n");
|
||||
req.append("Host: ").append(getRequestHost()).append("\r\n");
|
||||
req.append("Upgrade: websocket\r\n");
|
||||
req.append("User-Agent: BlockheadClient/JettyTests\r\n");
|
||||
req.append("Connection: ").append(connectionValue).append("\r\n");
|
||||
for (String header : headers)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue