mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-05-21 22:58:26 +00:00
Disable caching
This commit is contained in:
parent
5c2fac9352
commit
e861e6e549
@ -7,6 +7,7 @@ var http = require("http"),
|
||||
color = require("colorful"),
|
||||
sleep = require("sleep"),
|
||||
Buffer = require('buffer').Buffer,
|
||||
ChunkedStream = require("chunked"),
|
||||
httpsServerMgr = require("./httpsServerMgr");
|
||||
|
||||
var httpsServerMgrInstance = new httpsServerMgr();
|
||||
@ -115,7 +116,9 @@ function userRequestHandler(req,userRes){
|
||||
var proxyReq = (ifHttps ? https : http).request(options, function(res) {
|
||||
userRes.writeHead(res.statusCode,mergeCORSHeader(req.headers,res.headers));
|
||||
if(callback){
|
||||
res = new ChunkedStream(res);
|
||||
res.on('data',function(chunk){
|
||||
console.log("chunk",chunk);
|
||||
userRes.write(chunk);
|
||||
});
|
||||
res.on('end',function(){
|
||||
@ -227,6 +230,13 @@ function mergeCORSHeader(reqHeader,originHeader){
|
||||
targetObj["access-control-allow-methods"] = "GET, POST, PUT";
|
||||
targetObj["access-control-allow-headers"] = reqHeader['access-control-request-headers'] || "-___-||";
|
||||
|
||||
// Disable caching
|
||||
// If the response status is 304 not modified, the data event of response will not emmit
|
||||
targetObj["Transfer-Encoding"] = "chunked"
|
||||
targetObj["Cache-Control"] = "no-cache, no-store, must-revalidate";
|
||||
targetObj["Pragma"] = "no-cache";
|
||||
targetObj["Expires"] = 0;
|
||||
|
||||
return targetObj;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user