{"id":292,"date":"2006-11-18T12:47:54","date_gmt":"2006-11-18T12:47:54","guid":{"rendered":"http:\/\/neosmart.net\/blog\/archives\/292"},"modified":"2023-01-28T15:53:51","modified_gmt":"2023-01-28T21:53:51","slug":"how-to-apache_response_headers-on-iis","status":"publish","type":"post","link":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/","title":{"rendered":"How To: apache_response_headers() on IIS"},"content":{"rendered":"<p>Along with the release of our request_uri for IIS yesterday, we have another useful tip for a second function commonly found in WordPress plugins and other PHP redistributable scripts. apache_response_headers is used to get a list of all the headers sent out by a page, in the format of an associative array.\n<\/p>\n<p>IIS doesn\u2019t use this function, and before PHP5, there was no way to properly emulate its behavior. But on PHP5, it\u2019s nothing too difficult. Without further ado, here\u2019s the code:\n<\/p>\n<p><!--more--><pre lang='php'>&lt;?php \nif (!function_exists(&#039;apache_response_headers&#039;)){   \n\tfunction apache_response_headers(){   \n\t\t$nstList;   \n\t\tforeach (headers_list() as $nstHeader){   \n\t\t\t$nstObj      = substr($nstHeader, 0, strpos($nstHeader, &quot;: &quot;));   \n\t\t\t$nstObjVal   = substr($nstHeader,    strpos($nstHeader, &quot;: &quot;)+2);   \n\t\t\t$nstList&amp;#91;$nstObj&amp;#93; = $nstObjVal;   \n\t\t}   \n\t\treturn $nstList;   \n\t}   \n}\n?&gt;<\/pre><\/p>\n<p>It&#8217;s fairly straight forward code that involves changing the contents of a normal array into an associative one with a part of the string as the index name. It works because we know what form the content of the original array is going to take. To test the code:\n<\/p>\n<pre lang='php'>&lt;?php \n\/\/generate some headers:\nif (!headers_sent()) {\n\theader(&#039;Content-Type: plain\/text&#039;); \n\theader(&quot;Cache-Control: no-cache, must-revalidate&quot;); \n\theader(&quot;Expires: Mon, 26 Jul 1997 05:00:00 GMT&quot;); \n\theader(&#039;Content-type: application\/pdf&#039;); \n\theader(&#039;Content-Disposition: attachment; filename=&quot;downloaded.pdf&quot;&#039;);\n}\n\n\/\/Test the output. See what&#039;s in the array. \nprint_r(apache_response_headers());\n?&gt;<\/pre>\n<p>It&#8217;s always a good idea to use <code>if(!headers_sent()):<\/code> before attempting to send your own headers \u2013 just in case your function is being called when it shouldn&#8217;t be. The code fragment above returns the following when executed:\n<\/p>\n<pre>Array\r\n(\r\n    [X-Powered-By] =&gt; PHP\/5.1.6\r\n    [Cache-Control] =&gt; no-cache, must-revalidate\r\n    [Expires] =&gt; Mon, 26 Jul 1997 05:00:00 GMT\r\n    [Content-type] =&gt; application\/pdf\r\n    [Content-Disposition] =&gt; attachment; filename=\"downloaded.pdf\"\r\n)\r\n<\/pre>\n<p>You can test it yourself on a normal Apache webserver, but you don&#8217;t have to \u2014 it&#8217;s exactly the same thing, line-for-line, byte-for-byte.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Along with the release of our request_uri for IIS yesterday, we have another useful tip for a second function commonly found in WordPress plugins and other PHP redistributable scripts. apache_response_headers is used to get a list of all the headers &hellip; <a href=\"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[143,83,124],"class_list":["post-292","post","type-post","status-publish","format-standard","hentry","category-software","tag-apache","tag-iis","tag-php"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Along with the release of our request_uri for IIS yesterday, we have another useful tip for a second function commonly found in WordPress plugins and other PHP redistributable scripts. apache_response_headers is used to get a list of all the headers sent out by a page, in the format of an associative array. IIS doesn\u2019t use\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"NeoSmart Technologies\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/how-to-apache_response_headers-on-iis\\\/#article\",\"name\":\"How To: apache_response_headers() on IIS | The NeoSmart Files\",\"headline\":\"How To: apache_response_headers() on IIS\",\"author\":{\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/author\\\/neosmart\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/#organization\"},\"datePublished\":\"2006-11-18T12:47:54-06:00\",\"dateModified\":\"2023-01-28T15:53:51-06:00\",\"inLanguage\":\"en-US\",\"commentCount\":5,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/how-to-apache_response_headers-on-iis\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/how-to-apache_response_headers-on-iis\\\/#webpage\"},\"articleSection\":\"Software, apache, iis, php\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/how-to-apache_response_headers-on-iis\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/category\\\/software\\\/#listItem\",\"name\":\"Software\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/category\\\/software\\\/#listItem\",\"position\":2,\"name\":\"Software\",\"item\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/category\\\/software\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/how-to-apache_response_headers-on-iis\\\/#listItem\",\"name\":\"How To: apache_response_headers() on IIS\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/how-to-apache_response_headers-on-iis\\\/#listItem\",\"position\":3,\"name\":\"How To: apache_response_headers() on IIS\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/category\\\/software\\\/#listItem\",\"name\":\"Software\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/#organization\",\"name\":\"The NeoSmart Files\",\"description\":\"Recovery software and more\",\"url\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/author\\\/neosmart\\\/#author\",\"url\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/author\\\/neosmart\\\/\",\"name\":\"NeoSmart Technologies\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/how-to-apache_response_headers-on-iis\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f542321efe8fccee6fb0b3322c2f647e2ab44a861d6b18ff16a79d032f8574cd?s=96&d=mm&r=pg\",\"width\":96,\"height\":96,\"caption\":\"NeoSmart Technologies\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/how-to-apache_response_headers-on-iis\\\/#webpage\",\"url\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/how-to-apache_response_headers-on-iis\\\/\",\"name\":\"How To: apache_response_headers() on IIS | The NeoSmart Files\",\"description\":\"Along with the release of our request_uri for IIS yesterday, we have another useful tip for a second function commonly found in WordPress plugins and other PHP redistributable scripts. apache_response_headers is used to get a list of all the headers sent out by a page, in the format of an associative array. IIS doesn\\u2019t use\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/how-to-apache_response_headers-on-iis\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/author\\\/neosmart\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/author\\\/neosmart\\\/#author\"},\"datePublished\":\"2006-11-18T12:47:54-06:00\",\"dateModified\":\"2023-01-28T15:53:51-06:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/\",\"name\":\"The NeoSmart Files\",\"description\":\"Recovery software and more\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/neosmart.net\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How To: apache_response_headers() on IIS | The NeoSmart Files","description":"Along with the release of our request_uri for IIS yesterday, we have another useful tip for a second function commonly found in WordPress plugins and other PHP redistributable scripts. apache_response_headers is used to get a list of all the headers sent out by a page, in the format of an associative array. IIS doesn\u2019t use","canonical_url":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/#article","name":"How To: apache_response_headers() on IIS | The NeoSmart Files","headline":"How To: apache_response_headers() on IIS","author":{"@id":"https:\/\/neosmart.net\/blog\/author\/neosmart\/#author"},"publisher":{"@id":"https:\/\/neosmart.net\/blog\/#organization"},"datePublished":"2006-11-18T12:47:54-06:00","dateModified":"2023-01-28T15:53:51-06:00","inLanguage":"en-US","commentCount":5,"mainEntityOfPage":{"@id":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/#webpage"},"isPartOf":{"@id":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/#webpage"},"articleSection":"Software, apache, iis, php"},{"@type":"BreadcrumbList","@id":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/neosmart.net\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/neosmart.net\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/neosmart.net\/blog\/category\/software\/#listItem","name":"Software"}},{"@type":"ListItem","@id":"https:\/\/neosmart.net\/blog\/category\/software\/#listItem","position":2,"name":"Software","item":"https:\/\/neosmart.net\/blog\/category\/software\/","nextItem":{"@type":"ListItem","@id":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/#listItem","name":"How To: apache_response_headers() on IIS"},"previousItem":{"@type":"ListItem","@id":"https:\/\/neosmart.net\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/#listItem","position":3,"name":"How To: apache_response_headers() on IIS","previousItem":{"@type":"ListItem","@id":"https:\/\/neosmart.net\/blog\/category\/software\/#listItem","name":"Software"}}]},{"@type":"Organization","@id":"https:\/\/neosmart.net\/blog\/#organization","name":"The NeoSmart Files","description":"Recovery software and more","url":"https:\/\/neosmart.net\/blog\/"},{"@type":"Person","@id":"https:\/\/neosmart.net\/blog\/author\/neosmart\/#author","url":"https:\/\/neosmart.net\/blog\/author\/neosmart\/","name":"NeoSmart Technologies","image":{"@type":"ImageObject","@id":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/f542321efe8fccee6fb0b3322c2f647e2ab44a861d6b18ff16a79d032f8574cd?s=96&d=mm&r=pg","width":96,"height":96,"caption":"NeoSmart Technologies"}},{"@type":"WebPage","@id":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/#webpage","url":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/","name":"How To: apache_response_headers() on IIS | The NeoSmart Files","description":"Along with the release of our request_uri for IIS yesterday, we have another useful tip for a second function commonly found in WordPress plugins and other PHP redistributable scripts. apache_response_headers is used to get a list of all the headers sent out by a page, in the format of an associative array. IIS doesn\u2019t use","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/neosmart.net\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/#breadcrumblist"},"author":{"@id":"https:\/\/neosmart.net\/blog\/author\/neosmart\/#author"},"creator":{"@id":"https:\/\/neosmart.net\/blog\/author\/neosmart\/#author"},"datePublished":"2006-11-18T12:47:54-06:00","dateModified":"2023-01-28T15:53:51-06:00"},{"@type":"WebSite","@id":"https:\/\/neosmart.net\/blog\/#website","url":"https:\/\/neosmart.net\/blog\/","name":"The NeoSmart Files","description":"Recovery software and more","inLanguage":"en-US","publisher":{"@id":"https:\/\/neosmart.net\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"292","title":null,"description":null,"keywords":[],"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-23 20:03:58","updated":"2026-01-10 21:35:00","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/neosmart.net\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/neosmart.net\/blog\/category\/software\/\" title=\"Software\">Software<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow To: apache_response_headers() on IIS\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/neosmart.net\/blog\/"},{"label":"Software","link":"https:\/\/neosmart.net\/blog\/category\/software\/"},{"label":"How To: apache_response_headers() on IIS","link":"https:\/\/neosmart.net\/blog\/how-to-apache_response_headers-on-iis\/"}],"jetpack_shortlink":"https:\/\/wp.me\/p4xDa-4I","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/comments?post=292"}],"version-history":[{"count":1,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/292\/revisions"}],"predecessor-version":[{"id":5016,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/292\/revisions\/5016"}],"wp:attachment":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/media?parent=292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/categories?post=292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/tags?post=292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}