S
S
StopDesign2010-09-24 23:40:27
CMS
StopDesign, 2010-09-24 23:40:27

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.

UP .:
Most likely, I’m calling it a mistake in vain ... It’s just that this situation seems strange to me (and chrome).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
schursin, 2010-09-25
@schursin

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.

M
maxpain, 2010-09-25
@maxpain

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.

V
Vladimir Chernyshev, 2010-09-25
@VolCh

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

Moved


This page has moved to http://www.example.org/ .
Maybe something else is wrong?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question