// - [3] = "OK" } if (isset($argv[1])) { $host = $argv[1]; } else { $host = "localhost"; } if (isset($argv[2])) { $port = $argv[2]; } else { $port = "80"; } if (isset($argv[3])) { $path = $argv[3]; } else { $path = "/"; } $header = get_heads($host, $port, $path); echo $header["response"][1]; echo " " . $header["response"][2]; echo " " . $header["response"][3] . "\n"; foreach ($header as $header_name => $header_value) { if ($header_name == "response") { } else { echo "{$header_name}:{$header_value}\n"; } } preg_match("/([A-Za-z0-9\\=\\-\\:]*);/", $header["Set-Cookie"], $ck); echo $ck[1] . "\n"; $cookies = explode(":", $header["Set-Cookie"]); //var_dump($cookies);
<td align="center"><input type="submit" value="Request" name="requesting"></td> </table> </form> </div> <hr> <?php // If we have just POSTed a request, let's parse and print it. if (isset($_POST["requesting"])) { if ($_POST["host"] == "") { // I would like to make this fail nicer later. die("Please set a host value."); } // Run our function to get the headers. $header = get_heads($_POST["host"], '80', $_POST["resource"], $_POST["method"], $_POST["version"], $_POST["headers"]); // Let's display the full request so we can remember what's really going on, here. // First we need to "br" those newlines. $newq = nl2br($header["q"]); echo "<div style=\"background-color: #17c077;\">{$newq}</div>"; // Let's set an array so we can change the colors based on the type of status code. // Nifty. $bgs = array("1" => "6dafe1", "2" => "6dafe1", "3" => "d3b87f", "4" => "d27777", "5" => "fc5555"); echo "<div style=\"background-color: #" . $bgs[$header["response"][2][0]] . ";\">"; echo "<hr>"; echo "<b>"; echo $header["response"][1] . " " . $header["response"][2] . " " . $header["response"][3] . "<p>"; echo "</b>"; // This is sort of confusing. I needed to reference the actual response line // and wanted to be able to print out the query, as well. To do this, though // I needed to pass them in the return value. So we have to make sure we don't