Created
May 11, 2015 11:27
-
-
Save bararchy/00b50eca203f0999a79e to your computer and use it in GitHub Desktop.
Rewrite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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