scorn
A stupid HTTP client library.
r = Scorn.get('https://example.com/data.json')
p r # => { "data" => [ "foo", "bar" ] }
p r._response._c # => 200r = 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 theAcceptheader -
uauthorization:orauth:for theAuthorizationheader -
content_type:for theContent-Typeheader -
etag:orif_none_match:for theIf-None-Matchheader -
user_agent:for theAgentheader -
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