Socket
Book a DemoInstallSign in
Socket

http-requestor

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-requestor

1.0.4
bundlerRubygems
Version published
Maintainers
1
Created
Source

= http-requestor

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

== Installation

gem install http-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

=== HTTP Basic Authentication

HTTP::Requestor.send_basic_auth_request(url, username, password)

url => for example: "http://www.some_domain.com/some_path_value" only GET URL's supported currently

username => basic_auth_username

password => basic_auth_password

=== 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")})

=== More HTTP Verbs

You can also use other HTTP Verbs such as OPTIONS, PATCH, MOVE, HEAD, TRACE

  • By instantiating the HTTP::Requestor class

    http = HTTP::Requestor.new("http://www.mydomain.com")

    http.options(path, parameters, headers) http.patch(path, parameters, headers) http.move(path, parameters, headers) http.head(path, parameters, headers) http.trace(path, parameters, headers)

  • Directly calling the request method

    HTTP::Requestor.request(domain, request_type, path, parameters, headers)

    where request type can be any value within GET, POST, PUT, DELETE, OPTIONS, PATCH, MOVE, HEAD, TRACE

== Issues and Suggestions

Please report all the issues in the Github Issues Page, suggestions are also welcome. You can also mail me at rohit0981989[at]gmail[dot]com for the same.

FAQs

Package last updated on 25 Jan 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.