### Question:
MakeRequestHandler { @SuppressWarnings("boxing") protected static void setResponseHeaders(HttpServletRequest request, HttpServletResponse response, HttpResponse results) throws GadgetException { int refreshInterval = 0; if (results.isStrictNoCache() || "1".equals(request.getParameter(UriCommon.Param.NO_CACHE.getKey()))) { refreshInterval = 0; } else if (request.getParameter(UriCommon.Param.REFRESH.getKey()) != null) { try { refreshInterval = Integer.valueOf(request.getParameter(UriCommon.Param.REFRESH.getKey())); } catch (NumberFormatException nfe) { throw new GadgetException(GadgetException.Code.INVALID_PARAMETER, "refresh parameter is not a number", HttpResponse.SC_BAD_REQUEST); } } else { refreshInterval = Math.max(60 * 60, (int)(results.getCacheTtl() / 1000L)); } HttpUtil.setCachingHeaders(response, refreshInterval, false); response.setHeader("Content-Disposition", "attachment;filename=p.txt"); if (response.getContentType() == null) { response.setContentType("application/octet-stream"); } } @Inject  MakeRequestHandler(RequestPipeline requestPipeline,
      ResponseRewriterRegistry contentRewriterRegistry); void fetch(HttpServletRequest request, HttpServletResponse response); static final String UNPARSEABLE_CRUFT; static final String POST_DATA_PARAM; static final String METHOD_PARAM; static final String HEADERS_PARAM; static final String CONTENT_TYPE_PARAM; static final String NUM_ENTRIES_PARAM; static final String DEFAULT_NUM_ENTRIES; static final String GET_SUMMARIES_PARAM; static final String GET_FULL_HEADERS_PARAM; static final String AUTHZ_PARAM; }### Answer:
@Test public void testSetResponseHeaders() throws Exception { HttpResponse results = new HttpResponseBuilder().create(); replay(); MakeRequestHandler.setResponseHeaders(request, recorder, results); assertNotNull("Expires header not set", recorder.getHeader("Expires")); assertNotNull("Cache-Control header not set", recorder.getHeader("Cache-Control")); assertEquals("attachment;filename=p.txt", recorder.getHeader("Content-Disposition")); }
@Test public void testSetContentTypeHeader() throws Exception { HttpResponse results = new HttpResponseBuilder() .create(); replay(); MakeRequestHandler.setResponseHeaders(request, recorder, results); assertEquals("application/octet-stream", recorder.getHeader("Content-Type")); }
@Test public void testSetResponseHeadersNoCache() throws Exception { Map<String, List<String>> headers = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER); headers.put("Pragma", Arrays.asList("no-cache")); HttpResponse results = new HttpResponseBuilder() .addHeader("Pragma", "no-cache") .create(); replay(); MakeRequestHandler.setResponseHeaders(request, recorder, results); assertNotNull("Expires header not set", recorder.getHeader("Expires")); assertEquals("no-cache", recorder.getHeader("Pragma")); assertEquals("no-cache", recorder.getHeader("Cache-Control")); assertEquals("attachment;filename=p.txt", recorder.getHeader("Content-Disposition")); }