-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.2.js
67 lines (55 loc) · 1.41 KB
/
server.2.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//HTTP PROXY Code
/*
var http = require("http");
var options = {
host: "10.3.100.207",
port: 8080,
path: "http://api.btcxindia.com/ticker/",
headers: {
Host: "api.btcxindia.com",
}
};
http.get(options, function(res) {
//console.log(res);
res.pipe(process.stdout);
});*/
//HTTPS PROXY CODE
var Http = require('http');
var Tls = require('tls');
var req = Http.request({
host: '10.3.100.207',
port: 8080,
method: 'CONNECT',
path: 'api.btcxindia.com/ticker/:443',
});
req.on('connect', function (res, socket, head) {
var cts = Tls.connect({
host: 'api.btcxindia.com',
socket: socket
}, function () {
cts.write('GET / HTTP/1.1\r\nHost: api.btcxindia.com\r\n\r\n');
});
cts.on('data', function (data) {
console.log(data.toString());
});
});
req.end();
//Server Starter Code
/*
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(3000, '127.0.0.1');
console.log('Server running at http://127.0.0.1:3000/');
var express = require('express');
var app = express();
app.get('/wines', function(req, res) {
res.send([{name:'wine1'}, {name:'wine2'}]);
});
app.get('/wines/:id', function(req, res) {
res.send({id:req.params.id, name: "The Name", description: "description"});
});
app.listen(3001);
console.log('Listening on port 3001...');
*/