0

是否可以在 Grails Controller groovy 类中找出响应头的大小?

4

1 回答 1

0

现在无法测试它,但这样的东西应该可以工作:

def headers = response.getHeaderNames()

def size
headers.each { header ->
    def headerValue = response.getHeader(header)
    // get the size of headerValue in whatever unit you're looking for and add it to
    // the size variable
}

请记住,这是免费的,因为我现在没有设置来测试它,但 grails 响应对象只是HttpServletResponse的实例,所以它应该非常简单。

于 2012-09-25T19:10:12.367 回答