From b3b426046a199307ce80d01b604115890724cb22 Mon Sep 17 00:00:00 2001 From: Sergey Nastich Date: Mon, 10 Sep 2018 19:05:40 -0400 Subject: Add `Cache-Control: no-cache` to all responses of DriverRoutes. (#190) This change is intended to battle IE (even IE 11) caching all GET responses (and not making any new ones) that don't list those headers --- src/test/scala/xyz/driver/core/rest/DriverAppTest.scala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/scala/xyz/driver/core/rest/DriverAppTest.scala b/src/test/scala/xyz/driver/core/rest/DriverAppTest.scala index eda6a8c..8f552db 100644 --- a/src/test/scala/xyz/driver/core/rest/DriverAppTest.scala +++ b/src/test/scala/xyz/driver/core/rest/DriverAppTest.scala @@ -1,7 +1,8 @@ package xyz.driver.core.rest -import akka.http.scaladsl.model.{HttpMethod, StatusCodes} +import akka.http.scaladsl.model.headers.CacheDirectives.`no-cache` import akka.http.scaladsl.model.headers._ +import akka.http.scaladsl.model.{HttpMethod, StatusCodes} import akka.http.scaladsl.server.{Directives, Route} import akka.http.scaladsl.testkit.ScalatestRouteTest import com.typesafe.config.ConfigFactory @@ -81,4 +82,13 @@ class DriverAppTest extends AsyncFlatSpec with ScalatestRouteTest with Matchers header[`Access-Control-Allow-Methods`].get.methods should contain theSameElementsAs allowedMethods } } + + it should "respond with Pragma and Cache-Control (no-cache) headers" in { + val route = new TestApp(get(complete(StatusCodes.OK))) + Get(s"/api/v1/test") ~> route.appRoute ~> check { + status shouldBe StatusCodes.OK + header("Pragma").map(_.value()) should contain("no-cache") + header[`Cache-Control`].map(_.value()) should contain("no-cache") + } + } } -- cgit v1.2.3