lib/stub/server.rb in cf-uaac-2.0.0 vs lib/stub/server.rb in cf-uaac-2.0.1

- old
+ new

@@ -15,10 +15,11 @@ require 'date' require 'logger' require 'pp' require 'erb' require 'multi_json' +require 'rack' module Stub class StubError < RuntimeError; end class BadHeader < StubError; end @@ -86,10 +87,11 @@ #------------------------------------------------------------------------------ class Reply attr_accessor :status, :headers, :body def initialize(status = 200) @status, @headers, @cookies, @body = status, {}, [], "" end def to_s - reply = "HTTP/1.1 #{@status} OK\r\n" + message = Rack::Utils::HTTP_STATUS_CODES[@status] + reply = "HTTP/1.1 #{@status} #{message.upcase if message}\r\n" headers["server"], headers["date"] = "stub server", DateTime.now.httpdate headers["content-length"] = body.bytesize headers.each { |k, v| reply << "#{k}: #{v}\r\n" } @cookies.each { |c| reply << "Set-Cookie: #{c}\r\n" } reply << "\r\n" << body