Sha256: 7644f5b7a46234f84c230cee1bf945d8087415c5e6fc670741fbe7725f26ba96
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
# encoding: utf-8 module HTTPkit class Request include Support::Message include Adamantium attr_reader :http_method, :uri, :headers, :body, :http_version def initialize(http_method, uri, headers = {}, body = '', http_version = 1.1) @http_method = http_method # @uri = URI('http://' + uri) @uri = URI.join('http:///', uri).request_uri @headers = headers @body = Body.build(body) @http_version = http_version @sequences = SequenceHash.new end def with_headers(new_headers) with(2, headers.merge(new_headers)) end def with_body(new_body) with(3, Body.build(new_body)) end def with(index, argument) args = [http_method, uri, headers, body, http_version] args[index] = argument new_self(args) end def new_self(args) other = self.class.new(*args) @sequences.each { |(obj, id)| other.sequence(obj, id) } other end def sequence(obj, id = nil) @sequences[obj.object_id] ||= id end def body_included? body_present? end def body_present? !body.length_known? || !body.length.zero? end SequenceHash = Class.new(Hash) { include Adamantium::Mutable } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
httpkit-0.6.0 | lib/httpkit/request.rb |
httpkit-0.6.0.pre.5 | lib/httpkit/request.rb |