Sha256: aabab4c242731008b2f81fa07e3f8f1ebfce0c576d30eaaaa0b33bbbda9430e5

Contents?: true

Size: 998 Bytes

Versions: 32

Compression:

Stored size: 998 Bytes

Contents

use Rack::Lint
use Rack::ContentLength
use Rack::ContentType, "text/plain"
class DieIfUsed
  def each
    abort "body.each called after response hijack\n"
  end

  def close
    abort "body.close called after response hijack\n"
  end
end
run lambda { |env|
  case env["PATH_INFO"]
  when "/hijack_req"
    if env["rack.hijack?"]
      io = env["rack.hijack"].call
      if io.respond_to?(:read_nonblock) &&
         env["rack.hijack_io"].respond_to?(:read_nonblock)

        # exercise both, since we Rack::Lint may use different objects
        env["rack.hijack_io"].write("HTTP/1.0 200 OK\r\n\r\n")
        io.write("request.hijacked")
        io.close
        return [ 500, {}, DieIfUsed.new ]
      end
    end
    [ 500, {}, [ "hijack BAD\n" ] ]
  when "/hijack_res"
    r = "response.hijacked"
    [ 200,
      {
        "Content-Length" => r.bytesize.to_s,
        "rack.hijack" => proc do |io|
          io.write(r)
          io.close
        end
      },
      DieIfUsed.new
    ]
  end
}

Version data entries

32 entries across 32 versions & 5 rubygems

Version Path
unicorn-shopify-4.8.2.5.25 t/hijack.ru
unicorn-shopify-4.8.2.5.24 t/hijack.ru
unicorn-shopify-4.8.2.5.23 t/hijack.ru
unicorn-camilo-5.0.0 t/hijack.ru
unicorn-4.9.0 t/hijack.ru
unicorn-camilo-4.8.2.5.19 t/hijack.ru
unicorn-camilo-4.8.2.5.18 t/hijack.ru
unicorn-camilo-4.8.2.5.17 t/hijack.ru
unicorn-camilo-4.8.2.5.16 t/hijack.ru
unicorn-camilo-4.8.2.5.15 t/hijack.ru
unicorn-camilo-4.8.2.5.14 t/hijack.ru
unicorn-camilo-4.8.2.5.13 t/hijack.ru
unicorn-4.8.3 t/hijack.ru
unicorn-camilo-4.8.2.5.12 t/hijack.ru
unicorn-camilo-4.8.2.5.11 t/hijack.ru
unicorn-camilo-4.8.2.5.10 t/hijack.ru
unicorn-camilo-4.8.2.5.g0b28.dirty t/hijack.ru
unicorn-4.8.2 t/hijack.ru
unicorn-4.8.1.1.g9b565 t/hijack.ru
unicorn-4.8.1 t/hijack.ru