2010-01-11 19:52:22 |
Fırat Küçük |
description |
Hi,
response.setHeader() method behaves like put method of Hashtable class.
But there can be smart mechanism for some specific HTTP headers. For instance:
"Content-Type" makes duplicate record:
Test-Case:
Controller:
---------------------------------------------------------
public static void helloText() {
try {
response.setHeader("Content-Type", "text/html; charset=utf-8");
response.out.write("<b>hello</b>".getBytes());
} catch (Exception e) {
}
}
Request:
---------------------------------------------------------
GET /Application/helloText HTTP/1.1
Host: localhost:9000
Connection: close
Response:
---------------------------------------------------------
HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: close
Content-Length: 12
Content-Type: text/html; charset=utf-8
Content-Type: text/html
Date: Mon, 11 Jan 2010 19:36:39 GMT
Server: Play! Framework;dev
Set-Cookie: PLAY_ERRORS=; Path=/
Set-Cookie: PLAY_FLASH=; Path=/
Set-Cookie: PLAY_SESSION=067234602de391c9b44852504c609fe78bc5ffbe-%00___ID%3A51dbcbef-cbae-4001-a639-e76f1d6e68df%00; Path=/
known malfunction:
Apache mod_proxy deletes the second Content-Type header. So we can see the files as plain text. |
Hi,
response.setHeader() method behaves like put method of Hashtable class.
But there can be smart mechanism for some specific HTTP headers. For instance:
"Content-Type" makes duplicate record:
Test-Case:
Controller:
---------------------------------------------------------
public static void helloText() {
try {
response.setHeader("Content-Type", "text/html; charset=utf-8");
response.out.write("<b>hello</b>".getBytes());
} catch (Exception e) {
}
}
Request:
---------------------------------------------------------
GET /Application/helloText HTTP/1.1
Host: localhost:9000
Connection: close
Response:
---------------------------------------------------------
HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: close
Content-Length: 12
Content-Type: text/plain; charset=utf-8
Content-Type: text/html; charset=utf-8
Date: Mon, 11 Jan 2010 19:36:39 GMT
Server: Play! Framework;dev
Set-Cookie: PLAY_ERRORS=; Path=/
Set-Cookie: PLAY_FLASH=; Path=/
Set-Cookie: PLAY_SESSION=067234602de391c9b44852504c609fe78bc5ffbe-%00___ID%3A51dbcbef-cbae-4001-a639-e76f1d6e68df%00; Path=/
known malfunction:
Apache mod_proxy deletes the second Content-Type header. So we can see the files as plain text.
|
|