HTTP GETBir istemciden gelen istekleri üçüncü taraf bir web sitesine (örneğin, google) iletmek için bir proxy sunucusu oluşturmaya çalışıyorum . Proxy'min gelen istekleri hedef sitedeki ilgili yoluna yansıtması gerekiyor, yani müşterimin istediği url:
127.0.0.1/images/srpr/logo11w.png
Aşağıdaki kaynak sunulmalıdır:
http://www.google.com/images/srpr/logo11w.png
İşte bulduğum şey:
http.createServer(onRequest).listen(80);
function onRequest (client_req, client_res) {
client_req.addListener("end", function() {
var options = {
hostname: 'www.google.com',
port: 80,
path: client_req.url,
method: client_req.method
headers: client_req.headers
};
var req=http.request(options, function(res) {
var body;
res.on('data', function (chunk) {
body += chunk;
});
res.on('end', function () {
client_res.writeHead(res.statusCode, res.headers);
client_res.end(body);
});
});
req.end();
});
}
HTML sayfalarında iyi çalışır, ancak diğer dosya türleri için, yalnızca boş bir sayfa veya hedef siteden (farklı sitelerde değişiklik gösteren) bazı hata mesajları döndürür.


http, yüksek soyutlamaya düşük seviyesinden ilgili modüllerin bir emir gibidir:node,http,connect,expressalınan stackoverflow.com/questions/6040012/...