class Nastika::HTTP::Get
Crafting get requests
Attributes
headers[RW]
httpver[RW]
reqpath[RW]
Public Class Methods
new(reqpath=Nastika::Constants::DEFAULT_REQPATH, httpver=Nastika::Constants::DEFAULT_HTTPVER, headers=Nastika::Constants::DEFAULT_HEADERS)
click to toggle source
Intializes the Get
object. Params:
reqpath
-
Path to request
httpver
-
HTTP
version to use headers
-
Additional headers
# File lib/nastika/http_get_request.rb, line 16 def initialize(reqpath=Nastika::Constants::DEFAULT_REQPATH, httpver=Nastika::Constants::DEFAULT_HTTPVER, headers=Nastika::Constants::DEFAULT_HEADERS) self.reqpath = reqpath self.headers = headers self.httpver = httpver end
Public Instance Methods
to_s()
click to toggle source
Convert the object to a string.
# File lib/nastika/http_get_request.rb, line 25 def to_s payload = "" payload += "GET #{self.reqpath} HTTP/#{self.httpver}\r\n" self.headers.each do |key, val| payload += "#{key}: #{val}\r\n" end payload += "\r\n" return payload end