docs: public static ResponseEntity<InputStream> writeFileResponse(final AbstractDbArtifact artifact,
              final String filename, final long lastModified, final HttpServletResponse response,
              final HttpServletRequest request, final FileStreamingProgressListener progressListener) {
  
          ResponseEntity<InputStream> result;
  
          final String etag = artifact.getHashes().getSha1();
          final long length = artifact.getSize();
  
          response.reset();
          response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename);
          response.setHeader(HttpHeaders.ETAG, etag);
          response.setHeader(HttpHeaders.ACCEPT_RANGES, "bytes");
          if (lastModified > 0) {
              response.setDateHeader(HttpHeaders.LAST_MODIFIED, lastModified);
          }
  
          response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
          response.setBufferSize(BUFFER_SIZE);
  
          final ByteRange full = new ByteRange(0, length - 1, length);
          final List<ByteRange> ranges = new ArrayList<>();
  
          // Validate and process Range and If-Range headers.
          final String range = request.getHeader("Range");
          if (lastModified > 0 && range != null) {
              LOG.debug("range header for filename ({}) is: {}", filename, range);
  
              // Range header matches"bytes=n-n,n-n,n-n..."
              if (!range.matches("^bytes=\\d*-\\d*(,\\d*-\\d*)*$")) {
                  response.setHeader(HttpHeaders.CONTENT_RANGE, "bytes */" + length);
                  LOG.debug("range header for filename ({}) is not satisfiable: ", filename);
                  return new ResponseEntity<>(HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE);
              }
  
              // RFC: if the representation is unchanged, send me the part(s) that
              // I am requesting in
              // Range; otherwise, send me the entire representation.
              checkForShortcut(request, etag, lastModified, full, ranges);
  
              // it seems there are valid ranges
              result = extractRange(response, length, ranges, range);
              // return if range extraction turned out to be invalid
              if (result != null) {
                  return result;
              }
          }
  
          // full request - no range
          if (ranges.isEmpty() || ranges.get(0).equals(full)) {
              LOG.debug("filename ({}) results into a full request: ", filename);
              result = handleFullFileRequest(artifact, filename, response, progressListener, full);
          }
          // standard range request
          else if (ranges.size() == 1) {
              LOG.debug("filename ({}) results into a standard range request: ", filename);
              result = handleStandardRangeRequest(artifact, filename, response, progressListener, ranges);
          }
          // multipart range request
          else {
              LOG.debug("filename ({}) results into a multipart range request: ", filename);
              result = handleMultipartRangeRequest(artifact, filename, response, progressListener, ranges);
          }
  
          return result;
      }