Skip to content

Instantly share code, notes, and snippets.

@mrtc0
Created April 29, 2017 15:49
Show Gist options
  • Save mrtc0/e19c2e309561f6df2ac3e65fbc054137 to your computer and use it in GitHub Desktop.
Save mrtc0/e19c2e309561f6df2ac3e65fbc054137 to your computer and use it in GitHub Desktop.
require 'net_http_unix'
require 'json'
def sample(url)
req = Net::HTTP::Get.new(url)
client = NetX::HTTPUnix.new('unix:///var/lib/lxd/unix.socket')
resp = client.request(req)
puts resp.body
end
req = Net::HTTP::Post.new("/1.0/containers/admin/files?path=/tmp/test")
req.add_field('Content-Type', 'application/octet-stream')
req.body = File.read('rblxd.rb')
client = NetX::HTTPUnix.new('unix:///var/lib/lxd/unix.socket')
resp = client.request(req)
j = JSON.parse(resp.body)
p j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment