TitleCrawlerHandler : Return 400 on empty body.
This commit is contained in:
parent
236e35eebc
commit
09f2ff2903
|
@ -30,6 +30,13 @@ class TitleCrawlerHandler extends HttpHandler, Handler {
|
||||||
|
|
||||||
// I don't know if this one is ugly, but I wanted to show off a bit.
|
// I don't know if this one is ugly, but I wanted to show off a bit.
|
||||||
extension (exchange: HttpExchange) private def sendResponse(request: Array[Byte]): Unit = {
|
extension (exchange: HttpExchange) private def sendResponse(request: Array[Byte]): Unit = {
|
||||||
|
// Check for empty body.
|
||||||
|
if (request.isEmpty) {
|
||||||
|
exchange.sendResponseHeaders(400, -1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start processing.
|
||||||
exchange.sendResponseHeaders(200, 0)
|
exchange.sendResponseHeaders(200, 0)
|
||||||
val reader = new BufferedReader(new InputStreamReader(ByteArrayInputStream(request)))
|
val reader = new BufferedReader(new InputStreamReader(ByteArrayInputStream(request)))
|
||||||
val output = exchange.getResponseBody
|
val output = exchange.getResponseBody
|
||||||
|
|
Reference in a new issue