Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.use('/api', function(req, res) {
- var url = rewriteUrl(req.url);
- var newReq = request(url, function(error) {
- if (error) {
- logError(error);
- }
- });
- req.pipe(newReq).pipe(res);
- });
- app.use('/api', function(req, res) {
- var url = rewriteUrl(req.url);
- var newReq = http.request(url, function(newRes) {
- var headers = newRes.headers;
- // modify `headers` here ...
- res.writeHead(newRes.statusCode, headers);
- newRes.pipe(res);
- }).on('error', function(err) {
- res.statusCode = 500;
- res.end();
- });
- req.pipe(newReq);
- });
- req.pipe(newReq).pipe(res);
- req.pipe(newReq).on('response', function(res) {
- delete res.headers['user-agent'];
- // ...
- }).pipe(res);
- const req = request.get(url);
- req.pipefilter = function(response, dest) {
- // remove headers
- for(const h in response.headers) {
- dest.removeHeader(h);
- }
- // or modify
- dest.setHeader('Content-Type', 'text/html')
- }
- req.pipe(resp)
Add Comment
Please, Sign In to add comment