You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
667 B

9 years ago
  1. 'use strict'
  2. const test = require('tape')
  3. const request = require('req-then')
  4. const LocalWebServer = require('../../')
  5. const c = require('../common')
  6. test('compress', function (t) {
  7. t.plan(2)
  8. const ws = new LocalWebServer()
  9. ws.addCompression(true)
  10. ws.addStatic(__dirname)
  11. const server = ws.getServer()
  12. server.listen(8100, () => {
  13. request('http://localhost:8100/big-file.txt', { headers: { 'Accept-Encoding': 'gzip' } })
  14. .then(response => {
  15. t.strictEqual(response.res.statusCode, 200)
  16. t.strictEqual(response.res.headers['content-encoding'], 'gzip')
  17. })
  18. .then(server.close.bind(server))
  19. .catch(c.fail(t))
  20. })
  21. })