Skip to content

Instantly share code, notes, and snippets.

@arax
Created May 6, 2013 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save arax/5527509 to your computer and use it in GitHub Desktop.
Save arax/5527509 to your computer and use it in GitHub Desktop.
HTTPi with curb and SPNEGO, based on https://gist.github.com/pullmonkey/3179054
require 'rubygems'
require 'httpi'
require 'curb'
require 'pp'
require 'json'
################################
# kinit user@REALM
# kinit -k -t /ticket/path
################################
HOST = 'localhost'
PORT = 443
PATH = 'resource.json'
HTTPI.adapter = :curb
req = HTTPI::Request.new
req.url = URI.escape("https://#{HOST}:#{PORT}/#{PATH}")
# use spnego
req.auth.gssnegotiate
resp = HTTPI.get(req){ |http| http.use_ssl }
if resp.code == 200
STDERR.puts "Endpoint successfully queried, dumping JSON body:\n"
pp JSON.parse(resp.body)
else
STDERR.puts "Error :("
STDERR.puts resp.inspect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment