http-headers

Finding HTTP_REFERER empty/blank when using URL shortener site

I have a client who is trying to determine traffic metrics, to his site by way of those "URL shortened" sites: (tinyurl.com, bit.ly and x.co) to be specific, and to take action based on that traffic... We would have thought that the HTTP_REFERER variable would have held the referring resource name, the shortened URL from that service. ...

Setting optimum http caching headers and server params in ASP.Net MVC and IIS 7.5

I have an ASP.Net site (happens to be MVC, but that's not relevant here) with a few pages I'd like cached really well. Specifically I'd like to achieve: output cached on the server for 2 hours. if the file content on the server changes, that output cache should be flushed for that page cached in the browser for 10 minutes (i.e. don't...

Masking / Pointing subdomain to different server and keeping same url in address

This may be a question for Server Exchange but I am starting to feel pretty cozy here and I feel like someone here will definitely know the answer. We are currently rebuilding a php site in rails and have the new site that is being rebuilt on a linode box [nginx]. The live domain lives on a slicehost box [also niginx]. Upon launch we ...

Define custom User-agent header in the HTTP request?

I would like to get a glimpse of web-sites created for iPhone devices. In order to be able to view those sites I have to modify the User-agent header in the HTTP request that my browser sends. That way I can trick the web-server into believing that my browser is an iPhone browser, and then the web-server would send my the iPhone version ...

In Java, how to set the header of a Restlet Response?

I can't seem to figure out how to add headers to my restlet response. When I look at the available methods in the Response object, all I see is setStatus, setEntity, and setAttributes but none of these tell me how to set custom http headers on the response. For example, I have a GET call the returns something like the following: HTTP/1...

Why won't my Servlet respond to JSON requests in UTF-8?

My Servlet just won't use UTF-8 for JSON responses. MyServlet.java: public class MyServlet extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse res) throws Exception { PrintWriter writer = res.getWriter(); res.setCharacterEncoding("UTF-8"); res.setContentType("application/json; charse...

Creating and downloading CSV with PHP

I'm using PHP to create a CSV file from a database query. I run the query, set the headers, and load the page up in Firefox and the file promps for download and opens in excel just like it's supposed to. When I try it in IE, I get an error saying Internet Explorer cannot download ReportPrint.php from www.website.com. Internet Explorer w...

How to identify curl request

Is there a way to detect in my script whether the request is coming from normal web browser or some script executing curl. I can see the headers and can distinguish with "User-Agent and other few headers" but in curl fake headers can be set, so i am not able to track the request. Please suggest me ways about identifying the curl or othe...

Difference between three .htaccess expire rules

What's the difference between the following three .htaccess rules and when to use each, is there any special use cases that prefers one over the other?: Header set Cache-Control "max-age=290304000" Header set Expires "Thu, 15 Apr 2020 20:00:00 GMT" ExpiresDefault "access plus 10 years" ...

Setting the HTTP headers for XmlListModel in QML

Is it possible to set HTTP headers for an XmlListModel in QML? Suppose you want to use an XML feed which requires an API key as the data source for a list model. I can pass the API key as an URL attribute, but it would be more elegant to pass it in the HTTP headers. I didn't find anything in the documentation about this. Is it possible t...

Changing headers that IIS/ASP.NET sends. Side-effects?

IIS / ASP.NET sends HTTP headers to identify itself by default. Server Microsoft-IIS/7.5 X-AspNetMvc-Version 2.0 X-AspNet-Version 4.0.30319 X-Powered-By ASP.NET Is there any reason not to remove these? Considering the ASP.NET vulnerabilities recently discovered, some people recommend changing the Server hea...

Custom header not inserted in request in servlet

There's a thrird party app that needs to get information via custom http headers, so I wrote a simple test app that creates this headers and then redirects to a page that lists all headers. The header-generating servlet snippet is: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, I...

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

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? ...

gtm-http-fetcher modify HTTP Headers

Hey Everyone, I didn't know if anyone here has had experience with the gtm-http-fetcher provided by google. I am specifically looking to modify the HTTP headers in a request. Any help or examples would be appreciated. -Pat ...

Is it OK to HTTP redirect images?

Is it OK to return a 301 / 302 / 303 code when returning an image resource? I have done this in the past and it seems to work. Is it good practice and is it compatible with most browsers? ...

correct HTTP response headers to cause 304s after content expiration

I'd like an HTTP response to expire 24 hours from now (meaning the browser won't make any requests for that URL until tomorrow). But, if the request is re-issued tomorrow after expiration, I want to make sure the browser will send the right request headers so that the server will send a 304 instead of forcing the client to re-download th...

What determines if a downloaded file should be saved as read-only or read-write?

When you write some binary data in the http response stream (of Servlet etc) or using the Content-disposition header, what is the factor that determines whether the downloaded file is saved as readonly or has write permissions ? How can we control whether to make it read-only or not? Is that browser/OS dependant? ...

CRLF (\r\n) in PHP's header() function

Why/when does one has to use CRLF's at the end of header in PHP? Here is one example (it's not necessarily correct): header("method: POST\r\n"); header('Host: '.get_option('transact_url')."\r\n"); header('Content-type: application/x-www-form-urlencoded'); header('Content-length: '.strlen($transaction)."\r\n"); header($transaction."\r\n\...

Adding HTTP Headers and Post data in a System.Windows.Forms.WebBrowser

Hello! I'm trying to use the System.Windows.Forms.WebBrowser to make a request that both sends POST data and custom HTTP headers. I'd like to set the user-agent of the request as well. How could I do this? Thanks! ...

How to get final URL after following HTTP redirections in pure PHP?

What I'd like to do is find out what is the last/final URL after following the redirections. I would prefer not to use cURL. I would like to stick with pure PHP (stream wrappers). Right now I have a URL (let's say http://domain.test), and I use get_headers() to get specific headers from that page. get_headers will also return multiple ...