-
Notifications
You must be signed in to change notification settings - Fork 0
/
do.js
32 lines (32 loc) · 1020 Bytes
/
do.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Module to keep secrets local.
require('dotenv').config();
// Module to make HTTPS requests.
const https = require('https');
// Request options
const options = {
hostname: 'rally1.rallydev.com',
port: 443,
path: '/slm/webservice/v2.0/user/1',
method: 'GET',
auth: `${process.env.RALLY_USERNAME}:${process.env.RALLY_PASSWORD}`,
headers: {
'X-RallyIntegrationName':
process.env.RALLYINTEGRATIONNAME || 'RallyTree',
'X-RallyIntegrationVendor':
process.env.RALLYINTEGRATIONVENDOR || '',
'X-RallyIntegrationVersion':
process.env.RALLYINTEGRATIONVERSION || '1.0.4'
}
};
// Make an erroneous request in order to get a cookie identifying the server.
const request = https.request(options, response => {
console.log('Request made.');
response.on('end', () => {
const receivedCookie = response.headers['set-cookie'];
console.log(`Received cookie:\n${JSON.stringify(receivedCookie, null, 2)}`);
});
});
request.on('error', error => {
console.error(error);
});
request.end();