Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var host = "http://10.10.10.10";
- var uri = "/division/login/";
- var url = host + uri;
- var reqObj = {
- followAllRedirects:true,
- uri: url,
- method: "post",
- form: {username: 'name', password: 'word'}
- };
- request(reqObj, function(error, response, body){
- ....
- var reqObj = {
- followAllRedirects:false,
- followRedirects: false,
- followRedirect: false,
- uri: url,
- method: "post",
- form: {username: 'name', password: 'word'}
- };
- request(reqObj, function(error, response, body){
- if (response.statusCode === 302) {
- //hacking out the redirect path
- var newUri = host + "division/" + response.headers.location;
- var reqObj = {
- followAllRedirects:false,
- followRedirects: false,
- followRedirect: false,
- method: "get",
- uri: newUri
- };
- request(reqObj, function(error, response, body){
- //gives me status 401 unauthorized
- }.bind(this));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement