Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
Atle Haugan committed Feb 19, 2016
0 parents commit 5497e84
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
*.iml
node_modules/
28 changes: 28 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var express = require('express');
var http = require('http');
var app = express();


app.get('/', function (req, res) {
// var eventUrl = 'http://event.polarismedia.no/adressa/search/?dateFrom=2016-02-20&dateTo=2016-03-05&categories=8&page=1';
var eventUrl = "www.statoil.no";
var options = {
host: "www-proxy.statoil.no",
port: 80,
path: eventUrl,
headers: {
Host: eventUrl
}
};
http.get(options, function (res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
}); });
});

app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
46 changes: 46 additions & 0 deletions client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Created by ATLEH on 19.02.2016.
*/
var express = require('express');
var http = require('http');
var app = express();

app.get('/', function (req, res) {
// var url = 'http://event.polarismedia.no/adressa/search/?dateFrom=2016-02-20&dateTo=2016-03-05&categories=8&page=1';
var eventHost = 'event.polarismedia.no';
var eventPath = '/adressa/events/11948';
var optionsWithProxy = {
host: "www-proxy.statoil.no",
port: 80,
path: "www.statoil.no",
headers: {
Host: "www.statoil.no"
}
};
var optionsWithoutProxy = {
host: eventHost,
port: 80,
path: eventPath
};

// Callback function is used to deal with response
var callback = function (response) {
// Continuously update stream with data
var body = '';
response.on('data', function (data) {
body += data;
});

response.on('end', function () {
// Data received completely.
console.log(body);
});
};
// Make a request to the server
var req = http.request(optionsWithoutProxy, callback);
req.end();
});

app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "whatsup",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.13.4"
}
}

0 comments on commit 5497e84

Please sign in to comment.