-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Atle Haugan
committed
Feb 19, 2016
0 parents
commit 5497e84
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea/ | ||
*.iml | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |