perl - Hiding GET variables with sockets -
i have script send request page. im trying figureout how surpress output, here code itself:
use io::socket; $domain = 'yahoo.com'; $socket=io::socket::inet->new( proto => 'tcp', peeraddr => $domain, peerport => '80', ) or return $!; print $socket "get /index.php http/1.0\r\n"; print $socket "host: ", $domain, "\r\n"; print $socket "connection: close", "\r\n"; print $socket "user-agent: mozilla/5.0 (compatible; msie 9.0; windows nt 6.1; trident/5.0)", "\r\n"; print $socket "accept: text/html, application/xhtml+xml, */*", "\r\n\r\n"; print while <$socket>;
here output.
http/1.0 200 ok server: nginx/1.4.7 content-type: text/html x-powered-by: php/5.4.27-1~dotdeb.0 set-cookie: phpsessid=k2bviiurukqdju1l26j4fat0q0; path=/ cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 pragma: no-cache date: sun, 18 may 2014 19:53:20 gmt expires: thu, 19 nov 1981 08:52:00 gmt x-page-speed: 119_1_jt x-xss-protection: 1; mode=block alternate-protocol: 80:quic apache works!
as can see shows full page headers @ top, want page output. how suppress output of server headers? , keep page data.
if trying make web requests, better use http
library.
for particular case, however, following should suffice. prints after first line \r\n
, because delimiter used separate headers content in http
protocol.
# following line has been replaced loop # print while <$socket>; $seennl = 0; while (<$socket>) { if ($seennl) { print; } elsif ($_ eq "\r\n"){ $seennl=1; } }
Comments
Post a Comment