Class: PHPRPC::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/phprpc/base_server.rb

Overview

class BaseServer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Request

Returns a new instance of Request.



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/phprpc/base_server.rb', line 307

def initialize(env)
  @params = env["QUERY_STRING"] ? CGI::parse(env["QUERY_STRING"].to_s) : {}
  if (env['REQUEST_METHOD'] == 'POST' and
  (env['CONTENT_TYPE'].nil? or 
   env['CONTENT_TYPE'].split(/\s*[;,]\s*/, 2)[0].downcase ==
   'application/x-www-form-urlencoded')) then
    # fix ebb bug, the read method of ebb can't return all bytes from the I/O stream
    if input_body = env['rack.input'].read then
      while chunk = env['rack.input'].read(512) do
        input_body << chunk
      end
    else
      input_body = ''
    end
    @params.update(CGI::parse(input_body))
  end
  @cookies = if env["HTTP_COOKIE"] then CGI::Cookie::parse(env["HTTP_COOKIE"].to_s) else {} end 
  @output_cookies = nil
  @output_hidden = nil
end

Instance Attribute Details

#cookiesObject

Returns the value of attribute cookies.



304
305
306
# File 'lib/phprpc/base_server.rb', line 304

def cookies
  @cookies
end

#paramsObject (readonly)

Returns the value of attribute params.



305
306
307
# File 'lib/phprpc/base_server.rb', line 305

def params
  @params
end

Instance Method Details

#[](key) ⇒ Object



328
329
330
331
332
333
# File 'lib/phprpc/base_server.rb', line 328

def [](key)
  params = @params[key]
  return '' unless params
  value = params[0]
  if value then value else "" end
end

#[]=(key, val) ⇒ Object



335
336
337
# File 'lib/phprpc/base_server.rb', line 335

def []=(key, val)
  @params[key] = val
end

#has_key?(key) ⇒ Boolean Also known as: key?, include?

Returns:

  • (Boolean)


343
344
345
# File 'lib/phprpc/base_server.rb', line 343

def has_key?(key)
  @params.has_key?(key)
end

#keysObject



339
340
341
# File 'lib/phprpc/base_server.rb', line 339

def keys
  @params.keys
end