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.



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/phprpc/base_server.rb', line 312

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.



309
310
311
# File 'lib/phprpc/base_server.rb', line 309

def cookies
  @cookies
end

#paramsObject (readonly)

Returns the value of attribute params.



310
311
312
# File 'lib/phprpc/base_server.rb', line 310

def params
  @params
end

Instance Method Details

#[](key) ⇒ Object



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

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

#[]=(key, val) ⇒ Object



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

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

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

Returns:

  • (Boolean)


348
349
350
# File 'lib/phprpc/base_server.rb', line 348

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

#keysObject



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

def keys
  @params.keys
end