class GData::HTTP::Request
Very simple class to hold everything about an HTTP request.
Attributes
body[RW]
The body of the request.
headers[RW]
The HTTP headers of the request.
method[RW]
The HTTP method being used in the request.
url[RW]
The URL of the request.
Public Class Methods
new(url, options = {})
click to toggle source
Only the URL itself is required, everything else is optional.
# File lib/gdata/http/request.rb, line 33 def initialize(url, options = {}) @url = url options.each do |key, value| self.send("#{key}=", value) end @method ||= :get @headers ||= {} end
Public Instance Methods
calculate_length!()
click to toggle source
Calculates and sets the length of the body.
# File lib/gdata/http/request.rb, line 62 def calculate_length! if not @headers['Content-Length'] and not chunked? and method != :get and method != :delete if @body @headers['Content-Length'] = @body.length else @headers['Content-Length'] = 0 end end end
chunked=(enabled)
click to toggle source
Sets if the request is using chunked transfer-encoding.
# File lib/gdata/http/request.rb, line 53 def chunked=(enabled) if enabled @headers['Transfer-Encoding'] = 'chunked' else @headers.delete('Transfer-Encoding') end end
chunked?()
click to toggle source
Returns whether or not a request is chunked.
# File lib/gdata/http/request.rb, line 44 def chunked? if @headers['Transfer-Encoding'] == 'chunked' return true else return false end end