### Question:
MakeRequestHandler implements ContainerConfig.ConfigObserver { @SuppressWarnings("boxing") protected void setResponseHeaders(HttpServletRequest request, HttpServletResponse response, HttpResponse results) throws GadgetException { int refreshInterval = 0; if (results.isStrictNoCache() || "1".equals(getParameter(request, Param.NO_CACHE.getKey(), null))) { refreshInterval = 0; } else if (getParameter(request, Param.REFRESH.getKey(), null) != null) { try { refreshInterval = Integer.valueOf(getParameter(request, Param.REFRESH.getKey(), null)); } 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); if (!"1".equals(getParameter(request, MULTI_PART_FORM_POST, null))) { response.setHeader("Content-Disposition", "attachment;filename=p.txt"); } if (response.getContentType() == null) { response.setContentType("application/octet-stream"); } } @Inject  MakeRequestHandler(
          ContainerConfig config,
          RequestPipeline requestPipeline,
          @RewriterRegistry(rewriteFlow = RewriteFlow.DEFAULT) ResponseRewriterRegistry contentRewriterRegistry,
          Provider<FeedProcessor> feedProcessorProvider, GadgetAdminStore gadgetAdminStore,
          Processor processor, LockedDomainService lockedDomainService); void fetch(HttpServletRequest request, HttpServletResponse response); void containersChanged(ContainerConfig config, Collection<String> changed,
      Collection<String> removed); static final String ALIAS_PARAM; 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; static final String MAX_POST_SIZE_KEY; static final String MULTI_PART_FORM_POST; static final String MULTI_PART_FORM_POST_IFRAME; static final String GADGETS_FEATURES; static final String CORE_IO; static final String UNPARSEABLE_CRUFT; static final int MAX_POST_SIZE_DEFAULT; static final String IFRAME_RESPONSE_PREFIX; static final String IFRAME_RESPONSE_SUFFIX; }### Answer:
@Test public void testSetResponseHeaders() throws Exception { HttpResponse results = new HttpResponseBuilder().create(); replay(); handler.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(); handler.setResponseHeaders(request, recorder, results); assertEquals("application/octet-stream", recorder.getHeader("Content-Type")); }
@Test public void testSetResponseHeadersNoCache() throws Exception { Map<String, List<String>> headers = new TreeMap<String,List<String>>(String.CASE_INSENSITIVE_ORDER); headers.put("Pragma", Arrays.asList("no-cache")); HttpResponse results = new HttpResponseBuilder() .addHeader("Pragma", "no-cache") .create(); replay(); handler.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")); }