Sha256: 5ee6087dc700800f68d6694dddc7d970b308d4ceebade784e6ec265c10f6ab03
Contents?: true
Size: 1.72 KB
Versions: 2
Compression:
Stored size: 1.72 KB
Contents
class HTTP::Session class Cache class Entry class << self # Deserializes from a JSON primitive type. def deserialize(h) req = h[:req] req = HTTP::Session::Request.new(HTTP::Request.new(req)) res = h[:res] res[:request] = req res[:body] = HTTP::Session::Response::StringBody.new(res[:body]) res = HTTP::Session::Response.new(HTTP::Response.new(res)) new(req, res) end end # @!attribute [r] request # @return [Request] attr_reader :request # @!attribute [r] response # @return [Response] attr_reader :response # Returns a new instance of Entry. def initialize(req, res) @request = req @response = res end # @param [Request] req │ # @return [Response] def to_response(req) h = serialize_response h[:request] = req h[:body] = HTTP::Session::Response::StringBody.new(h[:body]) HTTP::Session::Response.new(HTTP::Response.new(h)) end # Serializes to a JSON primitive type. def serialize { req: serialize_request, res: serialize_response } end private def serialize_request { verb: @request.verb, uri: @request.uri.to_s, headers: @request.headers.to_h } end def serialize_response { status: @response.status.code, version: @response.version, headers: @response.headers.to_h, proxy_headers: @response.proxy_headers.to_h, body: @response.body.to_s } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-http-session-2.1.0 | lib/http/session/cache/entry.rb |
ruby-http-session-1.0.1 | lib/http/session/cache/entry.rb |