Sha256: 9ae8f50d81a2347182a24c6e7024933176606847a959df9a72b9893eb98f0577
Contents?: true
Size: 969 Bytes
Versions: 87
Compression:
Stored size: 969 Bytes
Contents
require "net/https" require "multi_json" module CFoundry module TraceHelpers def request_trace(request) return nil unless request info = ["REQUEST: #{request[:method]} #{request[:url]}"] info << "REQUEST_HEADERS:" info << header_trace(request[:headers]) info << "REQUEST_BODY: #{request[:body]}" if request[:body] info.join("\n") end def response_trace(response) return nil unless response info = ["RESPONSE: [#{response[:status]}]"] info << "RESPONSE_HEADERS:" info << header_trace(response[:headers]) info << "RESPONSE_BODY:" begin parsed_body = MultiJson.load(response[:body]) info << MultiJson.dump(parsed_body, :pretty => true) rescue info << "#{response[:body]}" end info.join("\n") end private def header_trace(headers) headers.sort.map do |key, value| " #{key} : #{value}" end end end end
Version data entries
87 entries across 87 versions & 3 rubygems