+
+connect("/var/run/redis/redis.sock");
+ $redis->ping();
+ $redis->select(9);
+
+ $key = md5( $url . serialize($customHeader) );
+
+ if( $redis->exists( $key ) ){
+ return unserialize( $redis->get( $key ) );
+ }
+
+ $agent = "Retrieve HTTP headers online. v0.1";
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($ch, CURLOPT_USERAGENT, $agent);
+ curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
+
+ switch($method){
+ case("head"):
+ curl_setopt($ch, CURLOPT_NOBODY, true);
+ break;
+ case("post"):
+ curl_setopt($ch, CURLOPT_POST, true);
+ default:
+ break;
+ }
+
+ if ( ! empty($customHeader) ){
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $customHeader);
+ }
+
+ $response = curl_exec($ch);
+ if ( ! $response )
+ return false;
+ $request = curl_getinfo($ch, CURLINFO_HEADER_OUT);
+ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
+ $header = substr($response, 0, $header_size);
+ $host = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
+
+ $result = array($request, $header, $host);
+
+ # redis. remove this line if no redis
+ $redis->set( $key, serialize($result), 60 );
+
+ return $result;
+ }
+ if ( ! isset($_REQUEST['method']) || $_REQUEST['method'] != "" ){
+ $_REQUEST['method'] = 'get';
+ } else {
+ $_REQUEST['method'] = strtolower($_REQUEST['method']);
+ }
+ $header_info = getInfo($_REQUEST['url'], $_REQUEST['method'], $_REQUEST['header']);
+ if ( ! $header_info ){
+ echo "
Failure!
Requested URL: \"".htmlentities($_REQUEST['url'])."\"
Couldn't retrieve URL. Please check whether the website is available and try again.
";
+ } else {
+ ?>
+
Success!
+
+
Requested URL: ""
+Host: ""
+
+
+
Request Header:
+ ".htmlentities($header_info[0])."";
+ ?>
+
Response Header:
+ ";
+ echo htmlentities($header_info[1]);
+ echo "";
+ }
+ ?>
+
Entries are cached for 60 seconds.
+
+
Retrieve HTTP Headers Online!
+
Check the response headers for websites.
Enter a URL and hit the submit button.
+
+
+
+
+
+