diff --git a/akka-http-tests/src/test/scala/akka/http/server/BasicRouteSpecs.scala b/akka-http-tests/src/test/scala/akka/http/server/BasicRouteSpecs.scala index 1ef6c0ada8..4c18c042e9 100644 --- a/akka-http-tests/src/test/scala/akka/http/server/BasicRouteSpecs.scala +++ b/akka-http-tests/src/test/scala/akka/http/server/BasicRouteSpecs.scala @@ -167,7 +167,10 @@ class BasicRouteSpecs extends RoutingSpec { Get("/abc") ~> Route.seal { post { completeOk } ~ authorize(false) { completeOk } - } ~> check { status shouldEqual StatusCodes.MethodNotAllowed } + } ~> check { + status shouldEqual StatusCodes.MethodNotAllowed + responseAs[String] shouldEqual "HTTP method not allowed, supported methods: POST" + } Get("/abc") ~> Route.seal { authorize(false) { completeOk } ~ diff --git a/akka-http/src/main/scala/akka/http/server/RejectionHandler.scala b/akka-http/src/main/scala/akka/http/server/RejectionHandler.scala index c7f74f3849..828df9b73e 100644 --- a/akka-http/src/main/scala/akka/http/server/RejectionHandler.scala +++ b/akka-http/src/main/scala/akka/http/server/RejectionHandler.scala @@ -122,8 +122,8 @@ object RejectionHandler { complete(BadRequest, "Uri scheme not allowed, supported schemes: " + schemes) } .handleAll[MethodRejection] { rejections ⇒ - val methods = rejections.map(_.supported) - complete(MethodNotAllowed, List(Allow(methods)), "HTTP method not allowed, supported methods: " + methods.mkString(", ")) + val (methods, names) = rejections.map(r ⇒ r.supported -> r.supported.name).unzip + complete(MethodNotAllowed, List(Allow(methods)), "HTTP method not allowed, supported methods: " + names.mkString(", ")) } .handle { case AuthorizationFailedRejection ⇒