/** * Serializes the object using the registered ContentTypeEngine matching * the pre-specified content-type. * <p>This method commits the response.</p> * * @param object */ public void send(Object object) { if (object instanceof File) { file((File) object); } else { send(object, getContentType()); } }
private void commit(CharSequence content) { checkCommitted(); finalizeResponse(); // content type to TEXT_HTML if it's not set if (getContentType() == null) { contentType(HttpConstants.ContentType.TEXT_HTML); } try { if (content != null) { contentLength(content.toString().getBytes().length); httpServletResponse.getWriter().append(content); } log.trace("Response committed"); if (chunked) { httpServletResponse.flushBuffer(); } finishGZip(); } catch (IOException e) { throw new PippoRuntimeException(e); } }
public ServletOutputStream getOutputStream() { checkCommitted(); finalizeResponse(); // content type to OCTET_STREAM if it's not set if (getContentType() == null) { contentType(HttpConstants.ContentType.APPLICATION_OCTET_STREAM); } try { return httpServletResponse.getOutputStream(); } catch (IOException e) { throw new PippoRuntimeException(e); } }
public PrintWriter getWriter() { checkCommitted(); finalizeResponse(); if (getContentType() == null) { contentType(HttpConstants.ContentType.TEXT_HTML); } try { return httpServletResponse.getWriter(); } catch (IOException e) { throw new PippoRuntimeException(e); } }
/** * Copies the input stream to the response output stream and closes the input stream upon completion. * <p>This method commits the response.</p> * * @param input */ public void resource(InputStream input) { checkCommitted(); finalizeResponse(); // content type to OCTET_STREAM if it's not set if (getContentType() == null) { contentType(HttpConstants.ContentType.APPLICATION_OCTET_STREAM); } try { send(input); } catch (IOException e) { throw new PippoRuntimeException(e); } }
String contentType = routeContext.getResponse().getContentType(); contentType = routeContext.getResponse().getContentType();
/** * Copies the input stream to the response output stream as a download and closes the input stream upon completion. * <p>This method commits the response.</p> * * @param filename * @param input */ public void file(String filename, InputStream input) { checkCommitted(); // content type to OCTET_STREAM if it's not set if (getContentType() == null) { contentType(mimeTypes.getContentType(filename, HttpConstants.ContentType.APPLICATION_OCTET_STREAM)); } if (isHeaderEmpty(HttpConstants.Header.CONTENT_DISPOSITION)) { filenameHeader(filename); } finalizeResponse(); try { send(input); } catch (IOException e) { throw new PippoRuntimeException(e); } }