title: Jersey 1.17 rate limit
body: <p>I want to limit the download rate in my REST service, this is my code:</p>
  
  <pre><code>@GET
  @Path("/laboDownloadWithLimit")
  @Produces(MediaType.APPLICATION_OCTET_STREAM)
  public Response getFile()
  {
      final File file = new File("SampleVideo_1280x720_50mb.mp4");
  
      final StreamingOutput streamingOutput = new StreamingOutput()
      {
  
          @Override
          public void write(
              final OutputStream outputStream)
              throws IOException, WebApplicationException
          {
              final InputStream inputStream = new FileInputStream(file);
              final byte[] buffer = new byte[2048];
              int len;
              while ((len = inputStream.read(buffer)) != -1)
              {
                  outputStream.write(buffer, 0, len);
                  Thread.sleep(10);
              }
          }
  
      };
      return Response.ok(streamingOutput)
          .type(MediaType.APPLICATION_OCTET_STREAM_TYPE)
         .header("Content-Disposition", "attachment; filename=\"" + file.getName() + "\"" ).build();
  }
  </code></pre>
  
  <p>But I think that exists better way to solve this problem, what should I use? I'm using Jetty 7.4.5</p>