Sha256: 3e7adfe50304f80489fab9bac42997a4f26301982bea6e12890104e49eb06f97

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 Bytes

Contents

module M2R
  class Response
    # Adds Content-Length header based on body size
    # This is mostly required when you use bare
    # Response class without any framework on top of it.
    # HTTP clients require such header when there is
    # body in response. Otherwise they hang out.
    #
    # @api public
    module ContentLength
      def headers(value = GETTER)
        if value == GETTER
          h = super
          h['Content-Length'] ||= body.bytesize
          h
        else
          super
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
m2r-2.1.0 lib/m2r/response/content_length.rb