Use ignore_headers in proxy

This commit is contained in:
Brendan Coles
2015-08-16 11:29:30 +00:00
parent cf2f1093a7
commit e06198c320

View File

@@ -130,34 +130,34 @@ module BeEF
# but the final content-length forwarded back by the proxy is clearly bigger. Date header follows the same way.
response_headers = ""
if (response_status != -1 && response_status != 0)
ignore_headers = [
"Content-Encoding",
"Keep-Alive",
"Cache-Control",
"Vary",
"Pragma",
"Connection",
"Expires",
"Accept-Ranges",
"Date"]
headers.each_line do |line|
# stripping the Encoding, Cache and other headers
header_key = line.split(': ')[0]
header_value = line.split(': ')[1]
if !header_key.nil? &&
header_key != "Content-Encoding" &&
header_key != "Keep-Alive" &&
header_key != "Cache-Control" &&
header_key != "Vary" &&
header_key != "Pragma" &&
header_key != "Connection" &&
header_key != "Expires" &&
header_key != "Accept-Ranges" &&
header_key != "Date"
next if header_key.nil?
next if ignore_headers.include?(header_key)
if header_value.nil?
#headers_hash[header_key] = ""
else
# update Content-Length with the valid one
if header_key == "Content-Length"
header_value = response_body.size
response_headers += "Content-Length: #{header_value}\r\n"
response_headers += "Content-Length: #{response_body.size}\r\n"
else
response_headers += line
end
end
end
end
end
res = "#{version} #{response_status}\r\n#{response_headers}\r\n\r\n#{response_body}"
socket.write(res)