Hello,
I am using the Node
request module from inside the Node shell to submit a login form via an HTTP POST. If the login is successful, the server redirects to a 'home' page (with an HTTP GET).
The documentation for the
request module says that any and all redirects happen by default, and this indeed
is happening - I can see the redirect in the server log.
However, on the client side, I need to be able to get hold of the (html) response body of the final redirect. (In my present case, there is only 1 redirect to a home page but it obviously could be more than 1 redirects also in the general case.)
Here's my client-side code:
var request = require('request');
request.post('http://localhost:8080/login', {
form: {
user:'u',
password:'p'
}},
function(err, resp, body) {
console.log(body);
});
The problem is, the above code prints nothing on the console!
Question: How to print the response of the final (HTTP GET) redirect? Additionally, in case of a chain of redirects, is it possible to retrieve, on the client side, some info at least on the intermediate redirects - eg, at minimum their URLs but, ideally, also their HTTP method types, query parameters, and request bodies?
Further double-checking: If I use
curl against my server, I see the html of the final home page just fine:
$ curl -L -d 'user=u' -d 'password=p' http://localhost:8080/login
<html> ... </html>
$
Regards,
/HS
PS: I had posted this earlier on SO, but got no response there!