yahns.git  about / heads / tags
sleepy, multi-threaded, non-blocking application server for Ruby
blob 6b0e7dd5ab041bdeef136cde7d2028dc875e50ce 611 bytes (raw)
$ git show maint:lib/yahns/cap_input.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
# -*- encoding: binary -*-
# Copyright (C) 2013-2016 all contributors <yahns-public@yhbt.net>
# License: GPLv2 or later (https://www.gnu.org/licenses/gpl-2.0.txt)
# frozen_string_literal: true

# This is used as the @input/env["rack.input"] when
# input_buffering == true or :lazy
class Yahns::CapInput < Yahns::TmpIO # :nodoc:
  attr_writer :bytes_left

  def self.new(limit, tmpdir)
    rv = super(tmpdir)
    rv.bytes_left = limit
    rv
  end

  def write(buf)
    if (@bytes_left -= buf.size) < 0
      raise Unicorn::RequestEntityTooLargeError, "chunked body too big", []
    end
    super(buf)
  end
end

git clone git://yhbt.net/yahns.git
git clone https://yhbt.net/yahns.git