1

how to remove headers from Response (SimpleResult)

the example of code:

def NoCache[A](action: Action[A]): Action[A] = Action(action.parser) { request =>
    action(request) match {
        case s: SimpleResult[_] =>
            s.withHeaders(PRAGMA -> "no-cache")
            // remove all headers with name "ETAG" HERE ??
        case result => result
    }
}

i did not find this functionality in documentation.

thanks.

4

1 に答える 1

0

SimpleResultとはどちらもケース クラスであるためResponseHeader、それらをコピーしてヘッダーを変更できます。

...
val headers = s.header.headers - ETAG + (PRAGMA -> "no-cache")
s.copy(header = s.header.copy(headers = headers))
...
于 2013-02-28T18:07:36.333 に答える