Blame view

node_modules/stream-http/test/browser/cookie.js 510 Bytes
aaac7fed   liuqimichale   add
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
  var Buffer = require('buffer').Buffer
  var test = require('tape')
  
  var http = require('../..')
  
  test('cookie', function (t) {
    var cookie = 'hello=world'
    window.document.cookie = cookie
  
    http.get({
      path: '/cookie',
      withCredentials: false
    }, function (res) {
      var buffers = []
  
      res.on('end', function () {
        t.ok(new Buffer(cookie).equals(Buffer.concat(buffers)), 'hello cookie echoed')
        t.end()
      })
  
      res.on('data', function (data) {
        buffers.push(data)
      })
    })
  })