http-headers

Stop browser to make HTTP requests for images that should stay cached - mod_expires

放肆的年华 提交于 2019-12-17 15:34:14
问题 After reading many articles and some questions on here, I finally succeded in activating the Apache mod_expires to tell the browser it MUST cache images for 1 year . <filesMatch "\.(ico|gif|jpg|png)$"> ExpiresActive On ExpiresDefault "access plus 1 year" Header append Cache-Control "public" </filesMatch> And thankfully server responses seem to be correct: HTTP/1.1 200 OK Date: Fri, 06 Apr 2012 19:25:30 GMT Server: Apache Last-Modified: Tue, 26 Jul 2011 18:50:14 GMT Accept-Ranges: bytes

Retry-after HTTP response header - does it affect anything?

偶尔善良 提交于 2019-12-17 15:32:16
问题 If I want to politely refuse service on a web site due to temporary overload, the HTTP response 503 Service Unavailable seems appropriate. The spec mentions sending a Retry-after header with the 503. Is there any point? Does Retry-after affect anything? Do browsers pay any attention to it? 回答1: As far as i'm aware, no browser pays attention to a Retry-after header. Proxies and caches might, but Apparently, some browsers now include some level of support for Retry-After (though support is

How do you add a custom http header?

我是研究僧i 提交于 2019-12-17 15:29:42
问题 I'm looking to add custom http headers to a Ruby on Rails app that is currently hosted on Heroku. 回答1: Use: response.headers['HEADER NAME'] = 'HEADER VALUE' either in a specific method or to a before_filter method of your application controller depending on whether you need this to be added in a specific or to all of your responses. UPDATE for Rails 5 - February 24th, 2018 As noted by @BrentMatzelle in the comments, for Rails 5: response.set_header('HEADER NAME', 'HEADER VALUE') 回答2: In rails

What is http host header?

我与影子孤独终老i 提交于 2019-12-17 15:10:46
问题 Given that the TCP connection is already established when the HTTP request is sent, the IP address and port are implicitly known -- a TCP connection is an IP + Port. So, why do we need the Host header? Is this only needed for the case where there are multiple hosts mapped to the IP address implied in the TCP connection? 回答1: The host Header tells the webserver which virtual host to use (if set up). You can even have the same virtual host using several aliases (= domains and wildcard-domains).

using header() to rewrite filename in URL for dynamic pdf

泄露秘密 提交于 2019-12-17 10:57:48
问题 I have a php script that generates a pdf report. When we go to save the pdf document, the filename that Acrobat suggests is report_pdf, since the php script is named report_pdf.php. I would like to dynamically name the pdf file, so I don't have to type the appropriate name for the report each time that I save it. Asking on a news group, someone suggested this, where filename="July Report.pdf" is the intended name of the report <? header('Content-Type: application/pdf'); header('Content

Can I rely on Referer HTTP header?

风流意气都作罢 提交于 2019-12-17 10:53:09
问题 Can I rely on Referer HTTP header in my web application? I want to check if the user came from a particular domain/webpage, and if he or she did, then change the layout of my site accordingly. I know that people can disable Referer in their browsers. Any ideas how often users do that? Can I rely on Referer being present in 99%? 回答1: As a general rule, you should not trust the HTTP Referer Header for any matter of importance, except for purely informative statistical analysis of who your

Parsing HTTP_RANGE header in PHP

孤者浪人 提交于 2019-12-17 10:46:59
问题 Is there an existing way to parse the HTTP_RANGE header correctly in PHP? Thought I'd ask here before re-inventing the wheel. I am currently using preg_match('/bytes=(\d+)-(\d+)/', $_SERVER['HTTP_RANGE'], $matches); to parse the header but that does not cover all possible values of the header so I am wondering if there is a function or library that can do this already? Thanks in advance. 回答1: Rather use regex to test it before sending a 416. Then just parse it by exploding on the comma , and

CORS error :Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response

。_饼干妹妹 提交于 2019-12-17 10:44:43
问题 I am trying to send the request from one localhost port to the another. I am using angularjs on the frontend and node on the backend . Since it is CORS request, In node.js, i am using res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH'); res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization'); and in the angular.js service file, I am using return { getValues: $resource

Illegal characters in HTTP headers

时光怂恿深爱的人放手 提交于 2019-12-17 10:34:35
问题 I'm creating an HttpUrlConnection and need to set multiple custom headers. I'd like to do something along the lines of the following, but the contents of the header map needs to come from a single string. Are there any characters that are illegal or extremely rarely used in both HTTP header names and HTTP header values? HashMap<String, String> headers = new HashMap<String, String>(); // TODO: How can I fill the headers map reliably from a single string? HttpURLConnection c =

What's the de facto standard for a Reverse Proxy to tell the backend SSL is used?

自作多情 提交于 2019-12-17 10:20:10
问题 I have a reverse proxy that does HTTPS on the outside, but HTTP on the inside. This means that by default in-app URLs will have HTTP as the scheme, as this is the way it's being contacted. How can the proxy tell the backend that HTTPS should be used? 回答1: The proxy can add extra (or overwrite) headers to requests it receives and passes through to the back-end. These can be used to communicate information to the back-end. So far I've seen a couple used for forcing the use of https in URL