Skip to content

Instantly share code, notes, and snippets.

@trushkevich
Created March 2, 2016 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trushkevich/cc5b87e3b6f440738441 to your computer and use it in GitHub Desktop.
Save trushkevich/cc5b87e3b6f440738441 to your computer and use it in GitHub Desktop.
fix passenger headers issue (for passenger 5)
module PhusionPassenger
module Utils
# Utility functions that can potentially be accelerated by native_support functions.
module NativeSupportUtils
extend self
NULL = "\0".freeze
class ProcessTimes < Struct.new(:utime, :stime)
end
def split_by_null_into_hash(data)
args = data.split(NULL, -1)
args.pop
headers_hash = Hash.new
args.each_slice(2).to_a.each do |pair|
headers_hash[pair.first] = pair.last unless headers_hash.keys.include? pair.first
end
return headers_hash
end
def process_times
times = Process.times
return ProcessTimes.new((times.utime * 1_000_000).to_i,
(times.stime * 1_000_000).to_i)
end
end
end # module Utils
end # module PhusionPassenger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment