This patches changes two things: 1. If a module has a custom Content-Length, it will respect that instead of forcing its own. 2. If a request does not have anything in the body, the Content-Length header will not be set. Fix #6609 Fix #6587bug/bundler_fix
parent
53ff3051e1
commit
bff4b4d5fc
|
@ -391,8 +391,9 @@ class ClientRequest
|
|||
|
||||
#
|
||||
# Return the content length header
|
||||
#
|
||||
def set_content_len_header(clen)
|
||||
return "" if opts['chunked_size'] > 0
|
||||
return "" if clen == 0 || opts['chunked_size'] > 0 || (opts['headers'] && opts['headers']['Content-Length'])
|
||||
set_formatted_header("Content-Length", clen)
|
||||
end
|
||||
|
||||
|
|
|
@ -151,7 +151,26 @@ RSpec.describe Rex::Proto::Http::ClientRequest do
|
|||
{
|
||||
:set_host_header => { :result => "Host: [2001:DB8::1]:1234\r\n" },
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
"with modified Content-Length header",
|
||||
default_options.merge({
|
||||
'headers' => { 'Content-Length' => 1337 }
|
||||
}),
|
||||
{
|
||||
:set_content_len_header => { args: 0, result: ''}
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
"with 1024 bytes of Content-Length",
|
||||
default_options,
|
||||
{
|
||||
:set_content_len_header => { args: 1024, result: "Content-Length: 1024\r\n"}
|
||||
}
|
||||
],
|
||||
|
||||
].each do |c, opts, expectations|
|
||||
context c do
|
||||
subject(:client_request) { Rex::Proto::Http::ClientRequest.new(opts) }
|
||||
|
|
Loading…
Reference in New Issue