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.

19 lines
395 B

4 years ago
  1. var Buffer = require('buffer').Buffer
  2. var http = require('../../..')
  3. module.exports = function (self) {
  4. self.addEventListener('message', function (ev) {
  5. var url = ev.data
  6. http.get(url, function (res) {
  7. var buffers = []
  8. res.on('end', function () {
  9. self.postMessage(Buffer.concat(buffers).buffer)
  10. })
  11. res.on('data', function (data) {
  12. buffers.push(data)
  13. })
  14. })
  15. })
  16. }