Project

scorn

0.0
A long-lived project that still receives updates
A stupid HTTP client library. Consider with scorn.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.6

Runtime

 Project Readme

scorn

gem version

A stupid HTTP client library.

r = Scorn.get('https://example.com/data.json')

p r # => { "data" => [ "foo", "bar" ] }
p r._response._c # => 200
r = Scorn.get('https://httpbin.org/get', json: true)

p r._response._c # => 200
p r['args'] # => {}
p r['headers']['Host'] # => 'httpbin.org'
p r['headers']['Accept'] # => 'application/json'
p r['url'] # => 'https://httpbin.org/get'
r = Scorn.post(
  'https://httpbin.org/post',
  data: { source: 'src', target: 'tgt', n: -1 },
  debug: $stderr)

p r._response._c # => 200
p r._response._sta # => 'OK'
p r._response.code # => '200'

p r.class # => Hash
p r['form'] # => { 'n' => '-1', 'source' => 'src', 'target' => 'tgt' }
r = Scorn.post(
  'https://httpbin.org/post',
  json: { who: 'Doomberg', what: 'buy gold', when: -1 },
  debug: Scorn::Debugger.new)

p r['json'] # => { 'who' => 'Doomberg', 'what' => 'buy gold', 'when' => -1 }

p r._response._c # =>  200
p r['url'] # =>  'https://httpbin.org/post'
p r['headers']['Accept'] # =>  'application/json'

Options:

  • accept: for the Accept header
  • uauthorization: or auth: for the Authorization header
  • content_type: for the Content-Type header
  • etag: or if_none_match: for the If-None-Match header
  • user_agent: for the Agent header
  • ssl_verify: false, ssl_verify: :none, verify: false, as expected
r = Scorn.get(
  'https://httpbin.org/get',
  auth: 'Bearer toto-nada-xplus',
  json: true)

p r['headers']['Authorization'] # => 'Bearer toto-nada-xplus'

LICENSE

MIT, see LICENSE.txt