http-headers

Grade F on Add Expires headers

Hi, I used the YSlow Firefox add-on and it return the follow result: Grade F on Add Expires headers There are 8 static components without a far-future expiration date. * (no expires) http://localhost:63808/WebSite/css/Global.css?... * (no expires) http://localhost:63808/WebSite/css/BemVindo.css?... * (no expires) http://localhost:6380...

What is the point of If-Unmodified-Since/If-Modified-Since? Aren't they superseded by ETags?

There seem to be two distinct ways to implement conditional requests using HTTP headers, both of which can be used for caching, range requests, concurrency control etc...: If-Unmodified-Since and If-Modified-Since, where the client sends a timestamp of the resource. If-Modified and If-None-Modified, where the client sends an ETag repre...

How access to response http headers from 'didReceiveAuthenticationChallenge' delegate method

Hi all, I need to deal with an http authentication (401) using the NSURLConnection class, so I implemented the "connection:didReceiveAuthenticationChallenge:" delegate method. In this method, to respond to the server challenge, I need an information contained in the http server response headers (the WWW-Authenticate header one). My pr...

why and where we have to write header cache control?

what is the sense of writing these lines of codes header("Cache-Control: no-cache, must-revalidate"); header("Expires: May, 17 May 1983 05:00:00 GMT\n"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); and where we have to write these lines of codes? on the page where we do databse dealing or just any php pages? ...

HTTP If-None-Match vs. If-Match

I'm currently building up a PHP script that will answer HTTP "304 Not Modified" when required. (See question #2086712 for what I do so far). Currently I answer to the following: If-Modified-Since If-None-Match But I found out that 3 more headers can trigger a "conditional GET" (See http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.h...

`post form` parameters difference between firefox and mechanize (ruby/mechanize)

I am trying to figure out if mechanize sends correct post query. I want to log in to a forum (please see html source, mechanize log in my other question) but I get only the login page again. When looking into it I can see that firefox sends out post with parameters like auth_username=myusername&auth_password=mypassword&auth_login=Log...

Where should I set HTTP headers, such as Expires?

I want to deploy an app using Sinatra on Phusion Passenger w/ nginx. If I want to set the Expires header on my static content - stylesheets, say - there are appear to be three places where I could accomplish this. In my Sinatra app, using the API With Rack middleware In the server config for my deployment Which of these methods is t...

How to configure static content cache per folder and extension in IIS7?

I would like to set up rules in IIS7 for static content caching in my ASP.NET website. I have seen these articles, which details how to do it using the <clientCache /> element in web.config: Client Cache <clientCache> (IIS.NET) Add Expires or Cache Control Header to static content in IIS (Stack Overflow) However, this setting ap...

How to change the default HTTP OPTIONS parameters in Java

My java snippet looks like: ... String type = "text/plain;charset=UTF-8"; URL url = new URL("http://xxx/"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("OPTIONS"); conn.setRequestProperty("Content-Type", type); ... When I sniff what this sends it sends a OPTIONS /...

How does AssemblyResourceLoader/ASP.Net handle If-Modified-Since header?

I have an IHttpHandler similar to AssemblyResourceLoader. What it does is generate an image and then send it back to the browser. In AssemblyResourceLoader there is a code block like this: HttpCachePolicy cache = context.Response.Cache; cache.SetCacheability(HttpCacheability.Public); cache.VaryByParams["d"] = true; c...

How to test for "If-Modified-Since" HTTP Header support

Using PHP how can I accurately test that a remote website supports the "If-Modified-Since" HTTP header. From what I have read, if the remote file you GET has been modified since the date specified in the header request - it should return a 200 OK status. If it hasn't been modified, it should return a 304 Not Modified. Therefore my q...

REST - Modify Part of Resource - PUT or POST

I'm seeing a good bit of hand-waving on the subject of how to update only part of a resource (eg. status indicator) using REST. The options seem to be: Complain that HTTP doesn't have a PATCH or MODIFY command. However, the accepted answer on http://stackoverflow.com/questions/1672025/http-modify-verb-for-rest does a good job of show...

Cache-Control HTML Headers

In an effort to tell a browser's cache how to treat my site, I wanted to write some cache control rules in the header. There is a great resource here, but I cant seem to find the correct cache control code for my situation. Because my website is static, I want the browser to always keep the data in its cache. BUT, the pages that do chan...

Parsing HTTP_RANGE header in PHP

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

PHP: Post data with Headers....not working.

Simple Script <?php $host = "mysite.com"; $path = "/test.php"; $data = "drivingMeCrazy"; $data = urlencode($data); header("POST $path HTTP/1.1\r\n" ); header("Host: $host\r\n" ); header("Content-type: application/x-www-form-urlencoded; charset=utf-8\r\n" ); header("Content-length: " . strlen($data) . "\r\n" ); header("Connection: close...

Sanitation for URL used in Header: Location?

In a multi-step form process, I am receiving a URL as a form field. After processing, my PHP script redirects to that address using header("Location: ..."); Apart from the possibility of being misused as a redirect service for porn sites to generate harmless-looking links in E-Mails (Open Redirect, which can be helped by matching the U...

Background Intelligent Transfer Service and Amazon S3.

Hi I'm using SharpBITS to download file from AmazonS3. > // Create new download job. BitsJob > job = this._bitsManager.CreateJob(jobName, JobType.Download); > // Add file to job. > job.AddFile(downloadFile.RemoteUrl, downloadFile.LocalDestination); > // Resume > job.Resume(); It works for files which do no need authentication. Howeve...

How to evaluate http response codes from bash/shell script?

I have the feeling that I'm missing the obvious, but have not succeeded with man [curl|wget] or google ("http" makes such a bad search term). I'm looking for a quick&dirty fix to one of our webservers that frequently fails, returning status code 500 with an error message. Once this happens, it needs to be restarted. As the root cause se...

Does a cookie have to be set in the http header?

Would like to set cookies from the server (CGI - C) Can it be set after the header has been printed? Thanks. ...

How is a cookie dynamically set based on user input?

How is, for example, a shopping cart cookie set? Once something is added to the cart it "creates" the cookie but how does the next page know to send a new http header with this new cookie to the client? How is a cookie dynamically set based on user input? Is this functionality dependent on anything else? I did see this example, but ...