Answer the question
In order to leave comments, you need to log in
Content-Type and redirect?
What Content-Type should the server return if it redirects a request, for example, to an image? That is, the second server response will be with Content-Type: image/jpeg. It seemed to me that it didn't matter. My server returns text/html. But chrome considers this an error and prints a warning in the console.
Here is an example from the main page of Yandex:
Resource interpreted as image but transferred with MIME type .<br/>
Resource interpreted as image but transferred with MIME type text/plain.
Answer the question
In order to leave comments, you need to log in
You can return nothing but the title: "Location: newaddress/image.jpg ".
The browser will make a request for a new address, and there the type will be returned to it.
Checked:
<source="php">$picname = $_GET['picname']. '.jpg';
header('Content-Type: text/plain');
header('Location: '. $picname);
The server returned HTTP 302 Moved Permanently and Chrome obediently went to the desired URL, having already received HTTP 200 OK Content-Type: image/jpeg.
Here is what, for example, Yandex produces:
GET / HTTP/1.1
Host: yandex.ru
…
HTTP/1.1 301 Moved Permanently
Date: Fri, 24 Sep 2010 22:18:20 GMT
Server: Apache/2.2.9 (Unix) mod_perl/ 2.0.4 Perl/v5.8.8
Location: www.yandex.ru/
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 189
Connection: close
Content-Type: text/html; charset=iso-8859-1
Unable to download source code for: yandex.ru/ Does
Chrome swear at it too?
Here is an example from the wiki en.wikipedia.org/wiki/URL_redirection :
HTTP/1.1 301 Moved Permanently
Location: www.example.org/
Content-Type: text/html
Content-Length: 174
Moved
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question