lib/toycol/server.rb in toycol-0.2.0 vs lib/toycol/server.rb in toycol-0.2.1
- old
+ new
@@ -53,11 +53,11 @@
::Toycol::PATH_INFO => "",
::Toycol::QUERY_STRING => "",
::Toycol::REQUEST_METHOD => "",
::Toycol::SERVER_NAME => "toycol_server",
::Toycol::SERVER_PORT => @port.to_s,
- ::Toycol::CONTENT_LENGTH => "",
+ ::Toycol::CONTENT_LENGTH => "0",
::Toycol::RACK_VERSION => Rack::VERSION,
::Toycol::RACK_INPUT => stringio(""),
::Toycol::RACK_ERRORS => $stderr,
::Toycol::RACK_MULTITHREAD => false,
::Toycol::RACK_MULTIPROCESS => false,
@@ -106,18 +106,19 @@
def assign_parsed_attributes!(request_message)
request_line, *request_headers, request_body = request_message.split("\r\n").reject(&:empty?)
request_method, request_path, = request_line.split
request_path, query_string = request_path.split("?")
- @env[REQUEST_METHOD] = request_method
- @env[PATH_INFO] = request_path
- @env[QUERY_STRING] = query_string || ""
+ @env[::Toycol::REQUEST_METHOD] = request_method
+ @env[::Toycol::PATH_INFO] = request_path
+ @env[::Toycol::QUERY_STRING] = query_string || ""
+ @env[::Toycol::CONTENT_LENGTH]
request_headers.each do |request_header|
k, v = request_header.split(":").map(&:strip)
- @env[k.tr("-", "_").upcase] = v
+ @env["::Toycol::#{k.tr("-", "_").upcase}"] = v
end
- @env[RACK_INPUT] = stringio(request_body)
+ @env[::Toycol::RACK_INPUT] = stringio(request_body)
end
end
end