Skip to content

Instantly share code, notes, and snippets.

@bararchy
Created May 11, 2015 11:27
Show Gist options
  • Save bararchy/00b50eca203f0999a79e to your computer and use it in GitHub Desktop.
Save bararchy/00b50eca203f0999a79e to your computer and use it in GitHub Desktop.
Rewrite
def self.rewrite_content_length(data)
new_size = data[:http_body].bytesize
if data[:http_headers].match(/Content-Length: (.*?)\r?\n/i)
data[:http_headers].gsub!(/Content-Length: (.*?)\r?\n/i, "Content-Length: #{new_size}\n")
else
data[:http_headers].strip!
data[:http_headers] << "\nContent-Length: #{new_size}\n\n"
end
data
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment