Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
rest-client-components
Advanced tools
= rest-client-components
RestClient on steroids !
Want to add transparent HTTP caching to the rest-client[http://github.com/archiloque/rest-client] gem ? It's as simple as: require 'restclient/components' require 'rack/cache' RestClient.enable Rack::Cache RestClient.get "http://some/cacheable/resource"
Want to log the requests in the commonlog format ? require 'restclient/components' RestClient.enable Rack::CommonLogger, STDOUT RestClient.get "http://some/resource"
Want to enable both ? require 'restclient/components' require 'rack/cache' RestClient.enable Rack::CommonLogger, STDOUT RestClient.enable Rack::Cache RestClient.get "http://some/cacheable/resource"
This works with any Rack middleware, thus you can reuse the wide range of existing Rack middleware to add functionalities to RestClient with very little effort. The order in which you enable components will be respected.
Note that the rest-client behaviour is also respected: you'll get back a RestClient::Response or RestClient exceptions as a result of your requests. If you prefer a more rack-esque approach, just disable the Compatibility component, and you will get back a response conform to the Rack SPEC: require 'restclient/components' RestClient.disable RestClient::Rack::Compatibility status, header, body = RestClient.get('http://some/url') In that case, you will only get exceptions for connection or timeout errors (RestClient::ServerBrokeConnection or RestClient::RequestTimeout)
See the examples folder for more details.
= Installation
gem install rest-client-components gem install rack-cache # if you want to use Rack::Cache
= Usage Example with Rack::Cache, and Rack::CommonLogger
require 'restclient/components' require 'rack/cache'
RestClient.enable Rack::CommonLogger
RestClient.enable Rack::Cache, :metastore => 'file:/tmp/cache/meta', :entitystore => 'file:/tmp/cache/body'
RestClient.get 'http://some/cacheable/resource'
resource = RestClient::Resource.new('http://some/cacheable/resource')
resource.get # get from origin server, and cache if possible resource.get # get from cache, if still fresh. resource.put(...) # will automatically invalidate the cache, so that a subsequent GET request on the same resource does not return the cached resource resource.get # get from origin server, and cache if possible
resource.get(:cache_control => 'no-cache') # explicitly tells to bypass the cache, requires rack-cache >= 0.5 and :allow_reload => true option
resource.delete(...) # will invalidate the cache resource.get # should raise a RestClient::ResourceNotFound exception
Now, you just need to make your resources cacheable, so unless you've already taken care of that, do yourself a favor and read:
= Dependencies
= COPYRIGHT
Copyright (c) 2009-2010 Cyril Rohr. See LICENSE for details.
FAQs
Unknown package
We found that rest-client-components demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.