fixed bug
Some checks failed
CI / build (push) Failing after 2m57s

This commit is contained in:
2025-01-24 18:15:06 +08:00
parent 423b749db9
commit 24a49779f9

View File

@@ -36,7 +36,12 @@ class ServerHandler(private val cache: Cache, private val serverPrefix: Path) :
if (method === HttpMethod.GET) {
val path = Path.of(msg.uri())
val prefix = path.parent
val key = path.fileName.toString()
val key = path.fileName?.toString() ?: let {
val response = DefaultFullHttpResponse(msg.protocolVersion(), HttpResponseStatus.NOT_FOUND)
response.headers()[HttpHeaderNames.CONTENT_LENGTH] = 0
ctx.writeAndFlush(response)
return
}
if (serverPrefix == prefix) {
try {
cache.get(key)