summaryrefslogtreecommitdiff
path: root/lib/net/http/generic_request.rb
diff options
context:
space:
mode:
-rw-r--r--lib/net/http/generic_request.rb92
1 files changed, 84 insertions, 8 deletions
@@ -1,14 +1,18 @@
# frozen_string_literal: false
-# HTTPGenericRequest is the parent of the Net::HTTPRequest class.
-# Do not use this directly; use a subclass of Net::HTTPRequest.
#
-# Mixes in the Net::HTTPHeader module to provide easier access to HTTP headers.
#
class Net::HTTPGenericRequest
include Net::HTTPHeader
- def initialize(m, reqbody, resbody, uri_or_path, initheader = nil)
@method = m
@request_has_body = reqbody
@response_has_body = resbody
@@ -53,15 +57,47 @@ class Net::HTTPGenericRequest
@body_data = nil
end
attr_reader :method
attr_reader :path
attr_reader :uri
- # Automatically set to false if the user sets the Accept-Encoding header.
- # This indicates they wish to handle Content-encoding in responses
- # themselves.
attr_reader :decode_content
def inspect
"\#<#{self.class} #{@method}>"
end
@@ -76,21 +112,45 @@ class Net::HTTPGenericRequest
super key, val
end
def request_body_permitted?
@request_has_body
end
def response_body_permitted?
@response_has_body
end
- def body_exist?
warn "Net::HTTPRequest#body_exist? is obsolete; use response_body_permitted?", uplevel: 1 if $VERBOSE
response_body_permitted?
end
attr_reader :body
def body=(str)
@body = str
@body_stream = nil
@@ -98,8 +158,24 @@ class Net::HTTPGenericRequest
str
end
attr_reader :body_stream
def body_stream=(input)
@body = nil
@body_stream = input