class Aws::S3::Plugins::Http200Errors::Handler

def call(context)

def call(context)
  @handler.call(context).on(200) do |response|
    return response if streaming_output?(context.operation.output)
    error = check_for_error(context)
    return response unless error
    context.http_response.status_code = 500
    response.data = nil
    response.error = error
  end
end

def check_for_error(context)

def check_for_error(context)
  xml = context.http_response.body_contents
  if xml.match(/<\?xml\s[^>]*\?>\s*<Error>/)
    error_code = xml.match(%r{<Code>(.+?)</Code>})[1]
    error_message = xml.match(%r{<Message>(.+?)</Message>})[1]
    S3::Errors.error_class(error_code).new(context, error_message)
  elsif incomplete_xml_body?(xml, context.operation.output)
    Seahorse::Client::NetworkingError.new(
      S3::Errors
        .error_class('InternalError')
        .new(context, 'Empty or incomplete response body')
    )
  end
end

def incomplete_xml_body?(xml, output)

Other incomplete xml bodies will result in an XML ParsingError.
Must have a member in the body and have the start of an XML Tag.
def incomplete_xml_body?(xml, output)
  members_in_body?(output) && !xml.match(/<\w/)
end

def members_in_body?(output)

before this method is called in incomplete_xml_body?.
of a string or blob, the body contents would have been checked first
non-structure shape will not have members in the body. In the case
are in the body for the case of a payload and a normal structure. A
Checks if the output shape is a structure shape and has members that
def members_in_body?(output)
  shape =
    if output[:payload_member]
      output[:payload_member].shape
    else
      output.shape
    end
  if structure_shape?(shape)
    shape.members.any? { |_, k| k.location.nil? }
  else
    false
  end
end

def streaming_output?(output)

Streaming outputs are not subject to 200 errors.
def streaming_output?(output)
  if (payload = output[:payload_member])
    # checking ref and shape
    payload['streaming'] || payload.shape['streaming'] ||
      payload.eventstream
  else
    false
  end
end

def structure_shape?(shape)

def structure_shape?(shape)
  shape.is_a?(Seahorse::Model::Shapes::StructureShape)
end