Browse Source

Add stress test server API

Ben Hsieh 8 years ago
parent
commit
0bf35df8f1
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      test-server/server.js

+ 9
- 2
test-server/server.js View File

108
   res.send('man')
108
   res.send('man')
109
 })
109
 })
110
 
110
 
111
+app.get('/stress/:id', function(req, res) {
112
+  res.sendFile(process.cwd() + '/public/github.png')
113
+})
114
+
111
 app.post('/mime', mimeCheck)
115
 app.post('/mime', mimeCheck)
112
 app.put('/mime', mimeCheck)
116
 app.put('/mime', mimeCheck)
113
 
117
 
137
   res.send(req.headers)
141
   res.send(req.headers)
138
 })
142
 })
139
 
143
 
140
-app.post('/upload', bodyParser.urlencoded({ extended: true }), (req, res) => {
144
+app.post('/upload', bodyParser.urlencoded({ extended : true }), (req, res) => {
141
   console.log(JSON.stringify(req.headers))
145
   console.log(JSON.stringify(req.headers))
142
   console.log(JSON.stringify(req.body))
146
   console.log(JSON.stringify(req.body))
143
   res.status(200).send(req.body)
147
   res.status(200).send(req.body)
144
 })
148
 })
145
 
149
 
146
-app.all('/timeout', (res, req) => {
150
+app.all('/timeout', (req, res) => {
151
+  setTimeout(function() {
152
+    res.status(408).send('request timed out.')
153
+  }, 5000)
147
 
154
 
148
 })
155
 })
149
 
156