Apply caching headers and stack trace before HTTP response status

Higher level filters may trigger extra behavior immediately on
setStatus(int), which means the stack trace attribute needs to
be set before the call, not after.

Also give the higher level filters visiblity to the suggested
caching headers, by applying them before setStatus(int).

Change-Id: Ic1556aaf0177f2f5957df2ed1fbd2d8b12d7119e
This commit is contained in:
Shawn Pearce 2014-11-10 15:52:48 -08:00
parent 08180de4de
commit c03cd517c3

@ -940,12 +940,12 @@ public class RestApiServlet extends HttpServlet {
public static void replyError(HttpServletRequest req,
HttpServletResponse res, int statusCode, String msg,
CacheControl c, @Nullable Throwable err) throws IOException {
res.setStatus(statusCode);
configureCaching(req, res, null, c);
replyText(req, res, msg);
if (err != null) {
RequestUtil.setErrorTraceAttribute(req, err);
}
configureCaching(req, res, null, c);
res.setStatus(statusCode);
replyText(req, res, msg);
}
static void replyText(@Nullable HttpServletRequest req,