Redirects and Raw Requests
This page covers following redirects and requests that send_request_cgi cannot handle.
send_request_cgi!
Section titled “send_request_cgi!”res = send_request_cgi!( { 'method' => 'GET', 'uri' => normalize_uri(target_uri.path, 'old') }, 20, # timeout 3 # redirect_depth)For a 30x response, it follows the Location header. The URI reached is stored in opts['redirect_uri'].
Take care with redirects after POST
Section titled “Take care with redirects after POST”reconfig_redirect_opts! changes POST to GET and clears data / vars_post. It is unsuitable if you need to follow a login POST while keeping the POST method. In that case, read Location yourself and construct the next send_request_cgi call.
res = send_request_cgi(...)if res && res.redirect? loc = res.redirection res = send_request_cgi( 'method' => 'GET', 'uri' => loc.path )endsend_request_raw
Section titled “send_request_raw”Use this when you need to depart from the HTTP specification or make the request look like a non-HTTP protocol.
send_request_raw({ 'method' => 'DESCRIBE', 'proto' => 'RTSP', 'version' => '1.0', 'uri' => '/' + ('../' * 560) + "\xcc\xcc\x90\x90" + '.smi'})send_request_raw( 'method' => 'GET', 'uri' => '/index.php', 'headers' => { 'Host' => "x\r\nX-Injected: 1" })For ordinary requests that need query or form construction, use send_request_cgi.
Controlling disconnect
Section titled “Controlling disconnect”# Third argument to cgisend_request_cgi({ 'uri' => '/' }, 20, false) # Do not disconnectsend_request_cgi({ 'uri' => '/next' }, 20, true)The default disconnect value for send_request_raw is false. This matters when you need to keep the connection open for keep-alive or findsock.
Temporary request to another host
Section titled “Temporary request to another host”send_request_cgi( 'method' => 'GET', 'uri' => '/health', 'rhost' => '10.10.11.200', 'rport' => 8080, 'SSL' => false, 'vhost' => 'internal.htb')
