class Nastika::HTTP

Implements the HTTP functionality

This response class is responsible for parsing reponses from the server. Right now the implementation is very bad. TODO: Fix implementation ASAP.

Attributes

host[RW]
port[RW]
request[RW]
response[RW]

Public Class Methods

new(host=nil, port=nil, request=nil) click to toggle source

Initialized the HTTP object Params:

host

Host to connect to

port

port to connect to

request

request object to send

# File lib/nastika/http.rb, line 21
def initialize(host=nil, port=nil, request=nil)
    self.host = host
    self.port = port
    self.request = request.to_s
end

Public Instance Methods

get_repsonse() click to toggle source

Sends the request and gets the response

# File lib/nastika/http.rb, line 28
def get_repsonse
  response = Nastika::HTTP::Response.new(make_request)
end
make_request() click to toggle source

Makes the request.

# File lib/nastika/http.rb, line 33
def make_request
  tcp = Nastika::TCP.new(self.host, self.port)
  tcp.payload = self.request
  
  begin
    tcp.connect
    tcp.send
  rescue => exception
    raise exception
  ensure
    tcp.close
  end
end