CmsWebdavRange range = new CmsWebdavRange(); range.setStart(Long.parseLong(rangeHeader.substring(0, dashPos))); range.setEnd(Long.parseLong(rangeHeader.substring(dashPos + 1, slashPos))); range.setLength(Long.parseLong(rangeHeader.substring(slashPos + 1, rangeHeader.length()))); } catch (NumberFormatException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); if (!range.validate()) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return null;
/** * Copy the contents of the specified input stream to the specified * output stream, and ensure that both streams are closed before returning * (even in the face of an exception).<p> * * @param item the RepositoryItem * @param ostream the output stream to write to * @param range the range the client wants to retrieve * * @throws IOException if an input/output error occurs */ protected void copy(I_CmsRepositoryItem item, ServletOutputStream ostream, CmsWebdavRange range) throws IOException { IOException exception = null; InputStream resourceInputStream = new ByteArrayInputStream(item.getContent()); InputStream istream = new BufferedInputStream(resourceInputStream, m_input); exception = copyRange(istream, ostream, range.getStart(), range.getEnd()); // Clean up the input stream try { istream.close(); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_INPUT_STREAM_0), e); } } // Rethrow any exception that has occurred if (exception != null) { throw exception; } }
/** * Copy the contents of the specified input stream to the specified * output stream, and ensure that both streams are closed before returning * (even in the face of an exception).<p> * * @param item the RepositoryItem * @param writer the writer to write to * @param range the range the client wants to retrieve * * @throws IOException if an input/output error occurs */ protected void copy(I_CmsRepositoryItem item, PrintWriter writer, CmsWebdavRange range) throws IOException { IOException exception = null; InputStream resourceInputStream = new ByteArrayInputStream(item.getContent()); Reader reader = new InputStreamReader(resourceInputStream); exception = copyRange(reader, writer, range.getStart(), range.getEnd()); // Clean up the input stream try { reader.close(); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_READER_0), e); } } // Rethrow any exception that has occurred if (exception != null) { throw exception; } }
CmsWebdavRange range = new CmsWebdavRange(); range.setStart(Long.parseLong(rangeHeader.substring(0, dashPos))); range.setEnd(Long.parseLong(rangeHeader.substring(dashPos + 1, slashPos))); range.setLength(Long.parseLong(rangeHeader.substring(slashPos + 1, rangeHeader.length()))); } catch (NumberFormatException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); if (!range.validate()) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return null;
/** * Copy the contents of the specified input stream to the specified * output stream, and ensure that both streams are closed before returning * (even in the face of an exception).<p> * * @param item the RepositoryItem * @param writer the writer to write to * @param range the range the client wants to retrieve * * @throws IOException if an input/output error occurs */ protected void copy(I_CmsRepositoryItem item, PrintWriter writer, CmsWebdavRange range) throws IOException { IOException exception = null; InputStream resourceInputStream = new ByteArrayInputStream(item.getContent()); Reader reader = new InputStreamReader(resourceInputStream); exception = copyRange(reader, writer, range.getStart(), range.getEnd()); // Clean up the input stream try { reader.close(); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_READER_0), e); } } // Rethrow any exception that has occurred if (exception != null) { throw exception; } }
String rangeDefinition = commaTokenizer.nextToken().trim(); CmsWebdavRange currentRange = new CmsWebdavRange(); currentRange.setLength(fileLength); currentRange.setStart(fileLength + offset); currentRange.setEnd(fileLength - 1); } catch (NumberFormatException e) { response.addHeader(HEADER_CONTENTRANGE, "bytes */" + fileLength); currentRange.setStart(Long.parseLong(rangeDefinition.substring(0, dashPos))); if (dashPos < (rangeDefinition.length() - 1)) { currentRange.setEnd( Long.parseLong(rangeDefinition.substring(dashPos + 1, rangeDefinition.length()))); } else { currentRange.setEnd(fileLength - 1); if (!currentRange.validate()) { response.addHeader(HEADER_CONTENTRANGE, "bytes */" + fileLength); response.setStatus(HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
/** * Copy the contents of the specified input stream to the specified * output stream, and ensure that both streams are closed before returning * (even in the face of an exception).<p> * * @param item the RepositoryItem * @param ostream the output stream to write to * @param range the range the client wants to retrieve * * @throws IOException if an input/output error occurs */ protected void copy(I_CmsRepositoryItem item, ServletOutputStream ostream, CmsWebdavRange range) throws IOException { IOException exception = null; InputStream resourceInputStream = new ByteArrayInputStream(item.getContent()); InputStream istream = new BufferedInputStream(resourceInputStream, m_input); exception = copyRange(istream, ostream, range.getStart(), range.getEnd()); // Clean up the input stream try { istream.close(); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_INPUT_STREAM_0), e); } } // Rethrow any exception that has occurred if (exception != null) { throw exception; } }
String rangeDefinition = commaTokenizer.nextToken().trim(); CmsWebdavRange currentRange = new CmsWebdavRange(); currentRange.setLength(fileLength); currentRange.setStart(fileLength + offset); currentRange.setEnd(fileLength - 1); } catch (NumberFormatException e) { response.addHeader(HEADER_CONTENTRANGE, "bytes */" + fileLength); currentRange.setStart(Long.parseLong(rangeDefinition.substring(0, dashPos))); if (dashPos < rangeDefinition.length() - 1) { currentRange.setEnd(Long.parseLong(rangeDefinition.substring( dashPos + 1, rangeDefinition.length()))); } else { currentRange.setEnd(fileLength - 1); if (!currentRange.validate()) { response.addHeader(HEADER_CONTENTRANGE, "bytes */" + fileLength); response.setStatus(HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);