2016-06-22 16 views
0

在状态码= 302上,应用程序重定向到的URL在哪里?它在响应头部分的字段uri中吗?我如何在飞行中修改它?如何修改http重定向上的网址?

case 'post': 
     r = request.post({ 
     url: newurl, 
     form: req.body, 
     headers: req.headers, 
     }, function callback(err, HttpResponse, body) { 
     debug(res.statusCode);  /* 302 */ 
     }); 

这里是从上面的POST请求的响应:

{ response: 
    { headers: 
     { 'content-type': 'text/html', 
     'content-length': '332', 
     location: 'https://11.21.164.11:10635/html/listing.tml?showError=&showMessage=Created%20successfully.', 
     uri: 'https://11.21.164.11:10635/html/listing.tml?showError=&showMessage=Created%20successfully.' }, 
    statusCode: 302, 
    body: '\r\n <html><head>\r\n<title>Found</title>\r\n </head></html>\r\n'} } 

回答

0

与302的状态码的HTTP响应将另外提供在位置报头字段的URL。用户代理(例如网络浏览器)通过具有此代码的响应被邀请,以对位置字段中指定的新URL进行第二次(否则相同)请求。

--from:https://en.wikipedia.org/wiki/HTTP_302

+0

是场上的位置URL修改在飞行中一旦我发现了302个状态码? – Rsk23