Module: HTTPX::Plugins::Expect::RequestMethods
- Defined in:
- lib/httpx/plugins/expect.rb
Instance Method Summary collapse
Instance Method Details
#initialize ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/httpx/plugins/expect.rb', line 45 def initialize(*) super return if @body.empty? threshold = @options.expect_threshold_size return if threshold && !@body.unbounded_body? && @body.bytesize < threshold return if Expect.no_expect_store.include?(origin) @headers["expect"] = "100-continue" end |
#response=(response) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/httpx/plugins/expect.rb', line 57 def response=(response) if response.is_a?(Response) && response.status == 100 && !@headers.key?("expect") && (@state == :body || @state == :done) # if we're past this point, this means that we just received a 100-Continue response, # but the request doesn't have the expect flag, and is already flushing (or flushed) the body. # # this means that expect was deactivated for this request too soon, i.e. response took longer. # # so we have to reactivate it again. @headers["expect"] = "100-continue" @informational_status = 100 Expect.no_expect_store.delete(origin) end super end |