1#!/usr/bin/env php 2<?php 3if ($argc < 3) { 4 exit("Usage: php send-http-data.php {port} {file} {:save}\n"); 5} 6 7$port = intval($argv[1]); 8$file = $argv[2]; 9 10 11$sock = stream_socket_client("tcp://127.0.0.1:{$port}"); 12fwrite($sock, file_get_contents($file)); 13stream_set_chunk_size($sock, 2*1024*1024); 14$data = fread($sock, 8192 * 128); 15 16if ($argc == 4 and $argv[3] == 'save') 17{ 18 file_put_contents("resp.html", $data); 19} 20else 21{ 22 echo $data; 23} 24