From 706a9fb377e493a9975309581f7b487f0496ffa9 Mon Sep 17 00:00:00 2001 From: Dan Milne Date: Fri, 10 Jan 2020 15:37:36 +1100 Subject: [PATCH] Investigate a plain net::http client for less dependancies --- lib/paapi/client.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/paapi/client.rb b/lib/paapi/client.rb index 058914d..946089c 100644 --- a/lib/paapi/client.rb +++ b/lib/paapi/client.rb @@ -98,7 +98,18 @@ module Paapi headers['Authorization'] = signature.headers['authorization'] headers['Content-Type'] = 'application/json; charset=utf-8' - Response.new( HTTP.headers(headers).post(endpoint, json: payload ) ) + #Response.new( HTTP.headers(headers).post(endpoint, json: payload ) ) + + request = Net::HTTP::Post.new(endpoint) + request.content_type = 'application/json; charset=UTF-8' + headers.each { |k, v| request[k] = v } + request.body = body + req_options = { use_ssl: uri.scheme == 'https' } + + Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| + http.request(request) + end + end end