module HTTPX::Plugins::Expect::RequestMethods

  1. lib/httpx/plugins/expect.rb

Methods

Public Class

  1. new

Public Instance

  1. response=

Public Class methods

new(*)
[show source]
   # File lib/httpx/plugins/expect.rb
45 def initialize(*)
46   super
47   return if @body.empty?
48 
49   threshold = @options.expect_threshold_size
50   return if threshold && !@body.unbounded_body? && @body.bytesize < threshold
51 
52   return if Expect.no_expect_store.include?(origin)
53 
54   @headers["expect"] = "100-continue"
55 end

Public Instance methods

response=(response)
[show source]
   # File lib/httpx/plugins/expect.rb
57 def response=(response)
58   if response.is_a?(Response) &&
59      response.status == 100 &&
60      !@headers.key?("expect") &&
61      (@state == :body || @state == :done)
62 
63     # if we're past this point, this means that we just received a 100-Continue response,
64     # but the request doesn't have the expect flag, and is already flushing (or flushed) the body.
65     #
66     # this means that expect was deactivated for this request too soon, i.e. response took longer.
67     #
68     # so we have to reactivate it again.
69     @headers["expect"] = "100-continue"
70     @informational_status = 100
71     Expect.no_expect_store.delete(origin)
72   end
73   super
74 end