-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathindex.js
64 lines (48 loc) · 1.26 KB
/
index.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
'use strict'
const etag = require('./etag')
const pkg = JSON.stringify(require('./package.json'))
const restify = require('restify')
const server = restify.createServer()
function payload () {
const data = {
a: Date.now() * Math.random(),
b: Date.now() * Math.random(),
c: Date.now() * Math.random(),
d: Date.now() * Math.random(),
e: Date.now() * Math.random(),
f: Date.now() * Math.random(),
g: Date.now() * Math.random(),
h: Date.now() * Math.random()
}
delete data.d
var val= 1
for (var i = 0; i < 100; i++) {
val += data.g
}
return '' + val
}
server.get('/a', function a (req, res, next) {
const tag = etag({ entity: pkg, algorithm: 'md5' })
if (!(tag instanceof Error)) {
res.setHeader('ETag', tag)
}
res.send(payload())
return next()
})
server.get('/b', function b (req, res, next) {
const tag = etag({ entity: pkg, algorithm: 'sha256' })
if (!(tag instanceof Error)) {
res.setHeader('ETag', tag)
}
res.send(payload())
return next()
})
server.get('/c', function c (req, res, next) {
const tag = etag({ entity: pkg, algorithm: 'sha512WithRsaEncryption' })
if (!(tag instanceof Error)) {
res.setHeader('ETag', tag)
}
res.send(payload())
return next()
})
server.listen(3000)