Sha256: 39e886a03742587e8dd73a003df1a573fa6455a3c5fe8e4cdfa3c32a22478e07
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
module NginxTail module HttpVersion def self.included(base) # :nodoc: base.class_eval do @@http_version_expression = Regexp.compile('HTTP/([0-9])\.([0-9])') def self.minor_version(http_version) return $1 if http_version =~ @@http_version_expression end def self.major_version(http_version) return $1 if http_version =~ @@http_version_expression end def self.to_http_version_s(http_version, which = :full) # http_version will be nil if $request == "-" (ie. "dodgy" HTTP requests) http_version.nil? ? "" : case which when :full then http_version when :major then self.major_version(http_version) when :minor then self.minor_version(http_version) end end # this ensures the below module methods actually make sense... raise "Class #{base.name} should implement instance method 'http_version'" unless base.instance_methods.map(&:to_s).include? 'http_version' end end def to_http_version_s(which = :full) self.class.to_http_version_s(self.http_version, which) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ntail-1.3.2 | lib/ntail/http_version.rb |