scala – Spray-Test gzip解码
发布时间:2020-12-16 18:08:13 所属栏目:安全 来源:网络整理
导读:我尝试喷涂测试 class FullTestKitExampleSpec extends Specification with Specs2RouteTest with UserController with HttpService { def actorRefFactory = system "The service" should { "return a greeting for GET requests to the root path" in { Ge
我尝试喷涂测试
class FullTestKitExampleSpec extends Specification with Specs2RouteTest with UserController with HttpService { def actorRefFactory = system "The service" should { "return a greeting for GET requests to the root path" in { Get("/user") ~> `Accept-Encoding`(gzip) ~> userRoute ~> check { val responsex = response responseAs[String] must contain("Test1") } } } } 我跟着路由器 trait UserController extends HttpService with Json4sSupport with CORSSupport{ override implicit def json4sFormats: Formats = DefaultFormats val userRoute = { cors { compressResponse(Gzip) { path("user") { get { complete { "Test1" } } ~ post { entity(as[UserRegister]) { person => complete { println(person.name) person.name } } } } } } } } 我使用GZIP压缩进行响应,但是
解决方法
在您的管道中包含解码(Gzip):
import spray.httpx.encoding.Gzip import spray.httpx.ResponseTransformation class MySprayRouteSpec extends FlatSpec with ShouldMatchers with ResponseTransformation with ScalatestRouteTest { Get("/") ~> mapHttpResponse(decode(Gzip))(userRoute) ~> check{ response.status should equal(OK) } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 如何在AngularJs中使用ng-options显示两个值?
- 关于weblogic下Did not meet stated content length of Out
- 关于Bugzilla WebService接口
- 手机端实现Bootstrap简单图片轮播效果
- scala – 如何忽略解析器组合器中的单行注释
- 网易资深运维工程师潘威:MySQL高可用在网易的最佳应用与实
- angularjs – 如果特定stateParam为空,如何重定向到状态
- 输入adb shell 时 提示error: more than one device and em
- axis2开发webservice知识整理
- 如何在scala中为两个或多个正则表达式使用模式匹配