P
P
Pix32019-02-25 11:20:02
Node.js
Pix3, 2019-02-25 11:20:02

Error in Rest Client when executing get request?

I want to make a GET request, but an error occurs:

statusCode:  302
headers:  { date: 'Mon, 25 Feb 2019 06:09:49 GMT',
  server: 'PHttp/2.6 Win32NT',
  'access-control-allow-origin': '*',
  'access-control-allow-headers': '*',
  'x-frame-options': 'SAMEORIGIN',
  location: '/auth/sign_in?ReturnUrl=%252home',
  'x-aspnet-version': '4.0.30319',
  'content-length': '147',
  'cache-control': 'private',
  'content-type': 'text/html',
  connection: 'close' }
Result:

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/auth/sign_in?ReturnUrl=%252home">here</a></h2>
</body><html>

The fact that the status 302 is displayed is normal. But headers should show Cookies, but they don't. And the result should be a full html + js page. instead, an authorization link is displayed. Where is the mistake?
var http = require('http');
const querystring = require('querystring')


var data = querystring.stringify({
  Login: "login",
  Password: "password"
})

var optionsget = {
  host: 'localhost',
  port: 8080,
  path: '/home',
  method: 'GET',
  auth: data,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': Buffer.byteLength(data)
  }
};

var reqGet = http.request(optionsget, function(res) {
    console.log("Status: ", res.statusCode);
    console.log("Headers: ", res.headers);

    res.on('data', function(d) {
        console.info('Result:\n');
        process.stdout.write(d);
    });

});

reqGet.end();
reqGet.on('error', function(e) {
    console.error("ERROR" +e);
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Okhotnikov, 2019-02-25
@tsepen

Judging by the status 302, the page has been moved to another url and now requires authorization
location: '/auth/sign_in?ReturnUrl=%252home',

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question