nickmagus Posted August 2, 2008 Share Posted August 2, 2008 is there a way to read the entire header not just what you can read with get? Quote Link to comment https://forums.phpfreaks.com/topic/117871-reading-the-entire-header/ Share on other sites More sharing options...
Wuhtzu Posted August 2, 2008 Share Posted August 2, 2008 Do you mean with PHP for futher processing or just an external application to view it? Live HTTP Headers add-on for Firefox for example... https://addons.mozilla.org/en-US/firefox/addon/3829 EDIT: From reading a couple of minutes my understanding is that all header values can be found in the $_SERVER superglobal array... http://dk2.php.net/manual/pl/reserved.variables.server.php Quote Link to comment https://forums.phpfreaks.com/topic/117871-reading-the-entire-header/#findComment-606281 Share on other sites More sharing options...
nickmagus Posted August 2, 2008 Author Share Posted August 2, 2008 i mean like how you can set the header with header() i want to read the header somehow. Quote Link to comment https://forums.phpfreaks.com/topic/117871-reading-the-entire-header/#findComment-606295 Share on other sites More sharing options...
Wuhtzu Posted August 3, 2008 Share Posted August 3, 2008 "To send a header with header()" and "i want to read the header somehow" is not the same and not related... What headers do you want to read? There is a a request header and response header for each and every "component" a given page is comprised of. So there is a request/response header for every image, every style sheet, every .js-file ect. So below is one out of 50-100 total header pairs needed for viewing http://www.phpfreaks.com/forums/ http://www.phpfreaks.com/forums/ GET /forums/ HTTP/1.1 Host: www.phpfreaks.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cookie: SMFCookie931=a%3A4%3A%7Bi%3A0%3Bs%3A5%3A%2240367%22%3Bi%3A1%3Bs%3A40%3A%2233f6e445ba965d4893b920d41744cc0debeeb1b3%22%3Bi%3A2%3Bi%3A1401746233%3Bi%3A3%3Bi%3A1%3B%7D; __utma=29981182.929747650489728800.1212493546.1217725239.1217756687.176; __utmz=29981182.1212493546.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); phpfreaks_session=5c0vfq84esd5rf77ojogtqond7; fbbb_=3326512757.1.1216050876451; PHPSESSID=thm8iltis57vd2k72p9j1d7t37; __utmb=29981182.4.10.1217756687; __utmc=29981182 If-Modified-Since: Sun, 03 Aug 2008 09:44:45 GMT HTTP/1.x 200 OK Date: Sun, 03 Aug 2008 09:46:38 GMT Server: Apache/2.2.8 (EL) Expires: Mon, 26 Jul 1997 05:00:00 GMT Cache-Control: private Pragma: no-cache Connection: close Content-Type: text/html; charset=ISO-8859-1 Transfer-Encoding: chunked Quote Link to comment https://forums.phpfreaks.com/topic/117871-reading-the-entire-header/#findComment-606602 Share on other sites More sharing options...
nickmagus Posted August 3, 2008 Author Share Posted August 3, 2008 what i want is the host value so that if there is no www i can redirect so there is one. Quote Link to comment https://forums.phpfreaks.com/topic/117871-reading-the-entire-header/#findComment-606748 Share on other sites More sharing options...
wildteen88 Posted August 3, 2008 Share Posted August 3, 2008 Use $_SERVER['HTTP_HOST'] to receive the hostname Quote Link to comment https://forums.phpfreaks.com/topic/117871-reading-the-entire-header/#findComment-606755 Share on other sites More sharing options...
nickmagus Posted August 3, 2008 Author Share Posted August 3, 2008 great how do you get the rest i.e "/.../.../blah.php" Quote Link to comment https://forums.phpfreaks.com/topic/117871-reading-the-entire-header/#findComment-606765 Share on other sites More sharing options...
chacha102 Posted August 3, 2008 Share Posted August 3, 2008 function getCurrentURL() { Global $_SERVER; $php_request_uri = htmlentities(substr($_SERVER['REQUEST_URI'], 0, strcspn($_SERVER['REQUEST_URI'], "\n\r")), ENT_QUOTES); if(isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) == "on")) { $protocol = "https://"; } else { $protocol = "http://"; } $host = $_SERVER['HTTP_HOST']; if($_SERVER['HTTP_PORT'] != "" && (($protocol == "http://" && $_SERVER['HTTP_PORT'] =! "80") || ($protocol == "https//" && $_SERVER['HTTP_PORT'] =! "443"))) { $port = ":" . $_SERVER['HTTP_PORT']; } else { $port = ""; } return $protocol . $host . $port . $php_request_uri; } Quote Link to comment https://forums.phpfreaks.com/topic/117871-reading-the-entire-header/#findComment-606771 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.