
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
SimpleHttpService is a simple Ruby library to make HTTP requests with customizable options for headers, timeouts, and retries. It provides a convenient way to create and send HTTP requests using a clean and simple interface.
Add this line to your application's Gemfile:
gem 'simple_http_service'
And then execute:
bundle install
Or install it yourself as:
gem install simple_http_service
You can create a new HTTP client using the SimpleHttpService.new method, which initializes an instance of SimpleHttpService::Client.
require 'simple_http_service'
client = SimpleHttpService.new(
url: 'https://api.example.com/endpoint',
http_method: :get,
headers: {
accept: 'application/json',
authorization: 'Bearer your_token',
content_type: 'application/json',
cookie: 'your cookie'
},
open_timeout: 5,
read_timeout: 10,
write_timeout: 5,
max_retries: 3,
additional_headers: {
'X-Request-Id': '12345'
}
)
After creating the client, you can call the call method to make the HTTP request:
response = client.call
puts response.body
url
(required): The URL for the HTTP request.http_method
(required): The HTTP method to use (:get, :post, :put).headers
: A hash of headers to include in the request.open_timeout
: Timeout for opening the connection (default is false).read_timeout
: Timeout for reading the response (default is false).write_timeout
: Timeout for writing the request (default is false).max_retries
: The number of times to retry the request in case of failure.request_body
: The body of the request (used for POST and PUT requests).additional_headers
: Additional headers to include in the request.Here's a complete example of using SimpleHttpService
to make a GET
request:
require 'simple_http_service'
client = SimpleHttpService.new(
url: 'https://api.example.com/endpoint',
http_method: :get,
headers: {
accept: 'application/json',
authorization: 'Bearer your_token'
},
open_timeout: 5,
read_timeout: 10
)
response = client.call
puts response.body
For a POST request with a request body:
require 'simple_http_service'
client = SimpleHttpService.new(
url: 'https://api.example.com/endpoint',
http_method: :post,
headers: {
accept: 'application/json',
authorization: 'Bearer your_token',
content_type: 'application/json'
},
request_body: { key: 'value' }.to_json,
open_timeout: 5,
read_timeout: 10,
write_timeout: 5
)
response = client.call
puts response.body
The library defines a custom error class SimpleHttpService::Error that you can use to handle exceptions:
begin
response = client.call
puts response.body
rescue SimpleHttpService::Error => e
puts "An error occurred: #{e.message}"
end
After checking out the repo, run bin/setup
to install dependencies. Then, run rspec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle install
. To release a new version, update the version number in version.rb
.
Bug reports and pull requests are welcome on GitHub at https://github.com/gklsan/simple_http_service.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the SimpleHttpService project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that simple_http_service demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.