http-requestor

A Wrapper around Net/HTTP which allows you to perform HTTP Requests in a
simple way.

Installation

geminstallhttp-requestor

Usage

Initialize a domain, and send request to multiple paths

http=HTTP::Requestor.new("http://www.mydomain.com")# This will initialize the HTTP::Requestor class
get_request=http.get(path,parameters,headers)post_request=http.post(path,parameters,headers)put_request=http.put(path,parameters,headers)delete_request=http.delete(path,parameters,headers)# path => for example: "/some_path"
# parameters => this is an optional parameter, if you want to send some parameters alongwith the request
# headers => this is also an optional parameter, you can pass a hash with stringified keys

Get a response right away

HTTP::Requestor.request(domain,request_type,path,parameters,headers)# domain => for example: "http://www.some_domain.com"
# request_type => GET|POST|PUT|DELETE
# path => for example: "/some_path"
# parameters => this is an optional parameter, if you want to send some parameters alongwith the request
# headers => this is also an optional parameter, you can pass a hash with stringified keys

OR you can do it the other way

HTTP::Requestor.request_with_url(url,request_type,data,headers)# url => for example: "http://www.some_domain.com/some_path_value"
# request_type => GET|POST|PUT|DELETE
# parameters => this is an optional parameter, if you want to send some parameters alongwith the request
# headers => this is also an optional parameter, you can pass a hash with stringified keys

Multipart Form Post

uri="http://some_domain/somepath"data={:file=>File.open("testfile.txt")}response=HTTP::Requestor.multipart_request(uri,"post | put",data)# If you already have the instance of HTTP::Requestor class then you can upload files as follows:
http=HTTP::Requestor.new("http://www.mydomain.com")response=http.post_multipart(some_path,{:file=>File.open("testfile.txt")})response=http.put_multipart(some_path,{:file=>File.open("testfile.txt")})