lib/CQHTTP/network.rb in CQHTTP-2.2.0 vs lib/CQHTTP/network.rb in CQHTTP-2.2.1
- old
+ new
@@ -21,12 +21,12 @@
# get url
#
# uri: URI
# params (optional): Hash, url query
def self.get(uri, params = nil) # => Hash
- puts 'GET URL:', uri if $DEBUG
uri.query = URI.encode_www_form params if params
+ puts 'GET URL:', uri if $DEBUG
error Net::HTTP.get_response(uri)
end
# post to url by form
#
@@ -41,9 +41,10 @@
#
# uri: URI
# body: Hash, post body
def self.post_json(uri, body)
puts 'POST URL:', uri if $DEBUG
+ puts 'POST JSON:', JSON.pretty_generate(body) if $DEBUG
error Net::HTTP.post(
uri,
body.to_json,
'Content-Type' => 'application/json'
)