diff --git a/socko-webserver/src/main/scala/org/mashupbots/socko/webserver/RequestHandler.scala b/socko-webserver/src/main/scala/org/mashupbots/socko/webserver/RequestHandler.scala index 74bb289..64075c4 100644 --- a/socko-webserver/src/main/scala/org/mashupbots/socko/webserver/RequestHandler.scala +++ b/socko-webserver/src/main/scala/org/mashupbots/socko/webserver/RequestHandler.scala @@ -110,7 +110,12 @@ class RequestHandler(server: WebServer, routes: PartialFunction[SockoEvent, Unit * @param e Message to process */ override def channelRead(ctx: ChannelHandlerContext, e: AnyRef) { + def isInvalid(httpRequest: HttpRequest): Boolean = HttpHeaders.getHost(httpRequest) == null + e match { + case httpRequest: FullHttpRequest if isInvalid(httpRequest) => + writeErrorResponse(ctx, HttpResponseStatus.BAD_REQUEST, new NullPointerException) + case httpRequest: FullHttpRequest => val event = HttpRequestEvent(ctx, httpRequest, httpConfig) @@ -125,6 +130,9 @@ class RequestHandler(server: WebServer, routes: PartialFunction[SockoEvent, Unit routes(event) } + case httpRequest: HttpRequest if isInvalid(httpRequest) => + writeErrorResponse(ctx, HttpResponseStatus.BAD_REQUEST, new NullPointerException) + case httpRequest: HttpRequest => val event = HttpRequestEvent(ctx, httpRequest, httpConfig)