unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob 54ca1edb9a9e0ef1f98afb828941302a5463d720 775 bytes (raw)
$ git show v0.97.1:test/rails/app-2.3.5/app/controllers/foo_controller.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
24
25
26
27
28
29
30
31
32
33
34
35
36
 
# -*- encoding: binary -*-

require 'digest/sha1'
class FooController < ApplicationController
  def index
    render :text => "FOO\n"
  end

  def xcookie
    cookies["foo"] = "cookie-#$$-#{session[:gotta_use_the_session_in_2_3]}"
    render :text => ""
  end

  def xnotice
    flash[:notice] = "session #$$"
    render :text => ""
  end

  def xpost
    if request.post?
      digest = Digest::SHA1.new
      out = "params: #{params.inspect}\n"
      if file = params[:file]
        loop do
          buf = file.read(4096) or break
          digest.update(buf)
        end
        out << "sha1: #{digest.to_s}\n"
      end
      headers['content-type'] = 'text/plain'
      render :text => out
    else
      render :status => 403, :text => "need post\n"
    end
  end
end

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