使用带有http分块传输的报头。 如何使用它设置cookie

使用预告片我想在页面stream式传输开始后设置一个cookie。 下面的代码尝试设置cookie。 它似乎返回正确的响应,但没有在浏览器中设置cookie(ff和chrome)。

var express = require('express'), http = require('http'), app = express(), server; app.use(app.router); app.all('*', function(req, res) { res.setHeader('Trailer', 'Set-Cookie'); res.setHeader('Content-Type', 'text/plain'); res.write("hi this is ogkla"); res.addTrailers({'Set-Cookie': "val=ogkla"}); res.end(); }); server = http.createServer(app).listen(80); module.exports = server; 

响应

 curl -iv --raw 'http://localhost/' * Adding handle: conn: 0x7fd87180aa89 * Adding handle: send: 0 * Adding handle: recv: 0 * Curl_addHandleToPipeline: length: 1 * - Conn 0 (0x7fd87180aa89) send_pipe: 1, recv_pipe: 0 * About to connect() to localhost port 80 (#0) * Trying ::1... * Trying 127.0.0.1... * Connected to localhost (127.0.0.1) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.30.0 > Host: localhost > Accept: */* > < HTTP/1.1 200 OK HTTP/1.1 200 OK < X-Powered-By: Express X-Powered-By: Express < Trailer: Set-Cookie Trailer: Set-Cookie < Content-Type: text/plain Content-Type: text/plain < Date: Wed, 26 Feb 2014 06:45:43 GMT Date: Wed, 26 Feb 2014 06:45:43 GMT < Connection: keep-alive Connection: keep-alive < Transfer-Encoding: chunked Transfer-Encoding: chunked < 10 hi this is ogkla 0 Set-Cookie: val=ogkla * Connection #0 to host localhost left intact 

我在这里做错了事。 需要帮助find它。

据我所知,大多数用户代理将parsing预告片,但不处理它们。