Class: EventMachine::Twitter::Request
- Inherits:
-
Object
- Object
- EventMachine::Twitter::Request
- Defined in:
- lib/em-twitter/request.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Request
constructor
A new instance of Request.
- #proxy? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/em-twitter/request.rb', line 8 def @options end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
8 9 10 |
# File 'lib/em-twitter/request.rb', line 8 def proxy @proxy end |
Instance Method Details
#proxy? ⇒ Boolean
48 49 50 |
# File 'lib/em-twitter/request.rb', line 48 def proxy? @proxy end |
#to_s ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/em-twitter/request.rb', line 15 def to_s content = query data = [] data << "#{request_method} #{request_uri} HTTP/1.1" data << "Host: #{@options[:host]}" if gzip? data << 'Connection: Keep-Alive' data << 'Accept-Encoding: deflate, gzip' else data << 'Accept: */*' end data << "User-Agent: #{@options[:user_agent]}" if @options[:user_agent] if put_or_post? data << "Content-Type: #{@options[:content_type]}" data << "Content-Length: #{content.bytesize}" end data << "Authorization: #{oauth_header}" if oauth? data << "Authorization: #{basic_auth_header}" if basic_auth? data << "Proxy-Authorization: Basic #{proxy.header}" if proxy? @options[:headers].each do |name, value| data << "#{name}: #{value}" end data << "\r\n" data = data.join("\r\n") data << content if post? || put? data end |