@Override public OutputStream writeResponseStatusAndHeaders(final long contentLength, final ContainerResponse context) throws ContainerException { try { final javax.ws.rs.core.Response.StatusType statusInfo = context.getStatusInfo(); if (statusInfo.getReasonPhrase() == null) { grizzlyResponse.setStatus(statusInfo.getStatusCode()); } else { grizzlyResponse.setStatus(statusInfo.getStatusCode(), statusInfo.getReasonPhrase()); } grizzlyResponse.setContentLengthLong(contentLength); for (final Map.Entry<String, List<String>> e : context.getStringHeaders().entrySet()) { for (final String value : e.getValue()) { grizzlyResponse.addHeader(e.getKey(), value); } } return grizzlyResponse.getOutputStream(); } finally { logger.debugLog("{0} - writeResponseStatusAndHeaders() called", name); } }
/** * Set the content length (in bytes) for this Response. * * If the <code>length</code> argument is negative - then {@link org.glassfish.grizzly.http.HttpPacket} * content-length value will be reset to <tt>-1</tt> and * <tt>Content-Length</tt> header (if present) will be removed. * * @param length The new content length */ public void setContentLength(final int length) { setContentLengthLong(length); }
/** * Set the content length (in bytes) for this Response. * * If the <code>length</code> argument is negative - then {@link org.glassfish.grizzly.http.HttpPacket} * content-length value will be reset to <tt>-1</tt> and * <tt>Content-Length</tt> header (if present) will be removed. * * @param length The new content length */ public void setContentLength(final int length) { setContentLengthLong(length); }
/** * Set the content length (in bytes) for this Response. * * If the <code>length</code> argument is negative - then {@link org.glassfish.grizzly.http.HttpPacket} * content-length value will be reset to <tt>-1</tt> and * <tt>Content-Length</tt> header (if present) will be removed. * * @param length The new content length */ public void setContentLength(final int length) { setContentLengthLong(length); }
/** * Set the content length (in bytes) for this Response. * * If the <code>length</code> argument is negative - then {@link org.glassfish.grizzly.http.HttpPacket} * content-length value will be reset to <tt>-1</tt> and * <tt>Content-Length</tt> header (if present) will be removed. * * @param length The new content length */ public void setContentLength(final int length) { setContentLengthLong(length); }
/** * Set the content length (in bytes) for this Response. * * If the <code>length</code> argument is negative - then {@link org.glassfish.grizzly.http.HttpPacket} * content-length value will be reset to <tt>-1</tt> and * <tt>Content-Length</tt> header (if present) will be removed. * * @param length The new content length */ public void setContentLength(final int length) { setContentLengthLong(length); }
/** * Set the content length (in bytes) for this Response. * * If the <code>length</code> argument is negative - then {@link org.glassfish.grizzly.http.HttpPacket} * content-length value will be reset to <tt>-1</tt> and * <tt>Content-Length</tt> header (if present) will be removed. * * @param length The new content length */ public void setContentLength(final int length) { setContentLengthLong(length); }
/** * Set the content length (in bytes) for this Response. * * If the <code>length</code> argument is negative - then {@link org.glassfish.grizzly.http.HttpPacket} * content-length value will be reset to <tt>-1</tt> and * <tt>Content-Length</tt> header (if present) will be removed. * * @param length The new content length */ public void setContentLength(final int length) { setContentLengthLong(length); }
/** * Set the content length (in bytes) for this Response. * * If the <code>length</code> argument is negative - then {@link org.glassfish.grizzly.http.HttpPacket} * content-length value will be reset to <tt>-1</tt> and * <tt>Content-Length</tt> header (if present) will be removed. * * @param length The new content length */ public void setContentLength(final int length) { setContentLengthLong(length); }
/** * Set the content length (in bytes) for this Response. * * If the <code>length</code> argument is negative - then {@link org.glassfish.grizzly.http.HttpPacket} * content-length value will be reset to <tt>-1</tt> and * <tt>Content-Length</tt> header (if present) will be removed. * * @param length The new content length */ public void setContentLength(final int length) { setContentLengthLong(length); }
/** * Set the content length (in bytes) for this Response. * * If the <code>length</code> argument is negative - then {@link org.glassfish.grizzly.http.HttpPacket} * content-length value will be reset to <tt>-1</tt> and * <tt>Content-Length</tt> header (if present) will be removed. * * @param length The new content length */ public void setContentLength(final int length) { setContentLengthLong(length); }
/** * Set the content length (in bytes) for this Response. * * If the <code>length</code> argument is negative - then {@link org.glassfish.grizzly.http.HttpPacket} * content-length value will be reset to <tt>-1</tt> and * <tt>Content-Length</tt> header (if present) will be removed. * * @param length The new content length */ public void setContentLength(final int length) { setContentLengthLong(length); }
/** * {@inheritDoc} */ @Override public void setContentLengthLong(long len) { if (isCommitted()) return; response.setContentLengthLong(len); }
/** * {@inheritDoc} */ @Override public void setContentLengthLong(long len) { if (isCommitted()) return; response.setContentLengthLong(len); }
/** * {@inheritDoc} */ @Override public void setContentLengthLong(long len) { if (isCommitted()) return; response.setContentLengthLong(len); }
/** * {@inheritDoc} */ @Override public void setContentLengthLong(long len) { if (isCommitted()) return; response.setContentLengthLong(len); }
/** * {@inheritDoc} */ @Override public void setContentLengthLong(long len) { if (isCommitted()) return; response.setContentLengthLong(len); }
/** * {@inheritDoc} */ @Override public void setContentLengthLong(long len) { if (isCommitted()) return; response.setContentLengthLong(len); }
public static void sendFile(final Response response, final File file) throws IOException { response.setStatus(HttpStatus.OK_200); // In case this sendFile(...) is called directly by user - pickup the content-type pickupContentType(response, file.getPath()); final long length = file.length(); response.setContentLengthLong(length); response.addDateHeader(Header.Date, System.currentTimeMillis()); if (!response.isSendFileEnabled() || response.getRequest().isSecure()) { sendUsingBuffers(response, file); } else { sendZeroCopy(response, file); } }
public static void sendFile(final Response response, final File file) throws IOException { response.setStatus(HttpStatus.OK_200); // In case this sendFile(...) is called directly by user - pickup the content-type pickupContentType(response, file.getPath()); final long length = file.length(); response.setContentLengthLong(length); response.addDateHeader(Header.Date, System.currentTimeMillis()); if (!response.isSendFileEnabled() || response.getRequest().isSecure()) { sendUsingBuffers(response, file); } else { sendZeroCopy(response, file); } }