@Test public void writesStatusAndHeaders() throws Exception { MultivaluedMap<String, Object> responseHeaders = new MultivaluedHashMap<>(); responseHeaders.putSingle("content-type", "text/plain"); when(containerResponse.getStatus()).thenReturn(200); when(containerResponse.getHttpHeaders()).thenReturn(responseHeaders); servletContainerResponseWriter.writeHeaders(containerResponse); verify(httpServletResponse).setStatus(eq(200)); verify(httpServletResponse).addHeader(eq("content-type"), eq("text/plain")); }
@Override public void writeHeaders(GenericContainerResponse response) throws IOException { if (servletResponse.isCommitted()) { return; } servletResponse.setStatus(response.getStatus()); if (response.getHttpHeaders() != null) { for (Map.Entry<String, List<Object>> e : response.getHttpHeaders().entrySet()) { String name = e.getKey(); for (Object o : e.getValue()) { String value; if (o != null && (value = HeaderHelper.getHeaderAsString(o)) != null) { servletResponse.addHeader(name, value); } } } } }
ServletContainerResponseWriter implements ContainerResponseWriter { @Override public void writeHeaders(GenericContainerResponse response) throws IOException { if (servletResponse.isCommitted()) { return; } servletResponse.setStatus(response.getStatus()); if (response.getHttpHeaders() != null) { for (Map.Entry<String, List<Object>> e : response.getHttpHeaders().entrySet()) { String name = e.getKey(); for (Object o : e.getValue()) { String value; if (o != null && (value = HeaderHelper.getHeaderAsString(o)) != null) { servletResponse.addHeader(name, value); } } } } } }
ServletContainerResponseWriter implements ContainerResponseWriter { @Override public void writeHeaders(GenericContainerResponse response) throws IOException { if (servletResponse.isCommitted()) { return; } servletResponse.setStatus(response.getStatus()); if (response.getHttpHeaders() != null) { for (Map.Entry<String, List<Object>> e : response.getHttpHeaders().entrySet()) { String name = e.getKey(); for (Object o : e.getValue()) { String value; if (o != null && (value = HeaderHelper.getHeaderAsString(o)) != null) { servletResponse.addHeader(name, value); } } } } } ServletContainerResponseWriter(HttpServletResponse response); }
ServletContainerResponseWriter implements ContainerResponseWriter { @Override public void writeHeaders(GenericContainerResponse response) throws IOException { if (servletResponse.isCommitted()) { return; } servletResponse.setStatus(response.getStatus()); if (response.getHttpHeaders() != null) { for (Map.Entry<String, List<Object>> e : response.getHttpHeaders().entrySet()) { String name = e.getKey(); for (Object o : e.getValue()) { String value; if (o != null && (value = HeaderHelper.getHeaderAsString(o)) != null) { servletResponse.addHeader(name, value); } } } } } ServletContainerResponseWriter(HttpServletResponse response); @Override @SuppressWarnings({"unchecked"}) void writeBody(GenericContainerResponse response, MessageBodyWriter entityWriter); @Override void writeHeaders(GenericContainerResponse response); }
ServletContainerResponseWriter implements ContainerResponseWriter { @Override public void writeHeaders(GenericContainerResponse response) throws IOException { if (servletResponse.isCommitted()) { return; } servletResponse.setStatus(response.getStatus()); if (response.getHttpHeaders() != null) { for (Map.Entry<String, List<Object>> e : response.getHttpHeaders().entrySet()) { String name = e.getKey(); for (Object o : e.getValue()) { String value; if (o != null && (value = HeaderHelper.getHeaderAsString(o)) != null) { servletResponse.addHeader(name, value); } } } } } ServletContainerResponseWriter(HttpServletResponse response); @Override @SuppressWarnings({"unchecked"}) void writeBody(GenericContainerResponse response, MessageBodyWriter entityWriter); @Override void writeHeaders(GenericContainerResponse response);  }