From fbe84bcbb85ddc1cde327faf382ef358e4c328e3 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 18 Apr 2022 20:33:56 +0100 Subject: Use 42 status code for CGI errors --- CHANGES.md | 6 +++++- server/src/net/usebox/gemini/server/Response.scala | 6 +++--- server/test/src/handlers/GeminiHandlerSpec.scala | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index edbc0cf..af22793 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,12 @@ # What's new? +## Release 1.3.5 - 2022-??-?? + + - Use 42 status code for CGI errors. + ## Release 1.3.4 - 2022-04-16 - - Updated dependencies + - Updated dependencies. - Internal refactoring preparing the service to support other protocols. ## Release 1.3.3 - 2022-01-14 diff --git a/server/src/net/usebox/gemini/server/Response.scala b/server/src/net/usebox/gemini/server/Response.scala index 1c2071f..82fa95d 100644 --- a/server/src/net/usebox/gemini/server/Response.scala +++ b/server/src/net/usebox/gemini/server/Response.scala @@ -137,18 +137,18 @@ case class Cgi( (status.toInt, meta, body) case _ => logger.warn(s"$scriptName: invalid CGI response") - respError(40, "Invalid response from CGI") + respError(42, "Invalid response from CGI") } case Right(exit) => logger.warn(s"$scriptName: failed to execute CGI (exit: $exit)") - respError(50, s"Error executing CGI") + respError(42, s"Error executing CGI") case Left(error) => logger.warn( s"$scriptName: failed to execute CGI (${error.getMessage()})" ) - respError(50, s"Error executing CGI") + respError(42, s"Error executing CGI") } } diff --git a/server/test/src/handlers/GeminiHandlerSpec.scala b/server/test/src/handlers/GeminiHandlerSpec.scala index f3545a0..f6da826 100644 --- a/server/test/src/handlers/GeminiHandlerSpec.scala +++ b/server/test/src/handlers/GeminiHandlerSpec.scala @@ -403,7 +403,7 @@ class GeminiHandlerSpec extends AnyFlatSpec with Matchers { .asInstanceOf[Cgi] val meta = "Error executing CGI" - bad.status should be(50) + bad.status should be(42) bad.meta should be(meta) bad.body should include(meta) } @@ -414,7 +414,7 @@ class GeminiHandlerSpec extends AnyFlatSpec with Matchers { .asInstanceOf[Cgi] val meta = "Error executing CGI" - bad.status should be(50) + bad.status should be(42) bad.meta should be(meta) bad.body should include(meta) } @@ -425,7 +425,7 @@ class GeminiHandlerSpec extends AnyFlatSpec with Matchers { .asInstanceOf[Cgi] val meta = "Invalid response from CGI" - bad.status should be(40) + bad.status should be(42) bad.meta should be(meta) bad.body should include(meta) } -- cgit v1.2.3