Skip to content

Commit 451b09d

Browse files
committed
Remove dependency on request.
We didn't really need it, and one of its dependencies had a security issue.
1 parent b25f20e commit 451b09d

File tree

3 files changed

+1144
-1143
lines changed

3 files changed

+1144
-1143
lines changed

lib/ldp-copy.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ const debug = require('./debug')
44
const fs = require('fs')
55
const mkdirp = require('fs-extra').mkdirp
66
const path = require('path')
7-
const request = require('request')
7+
const http = require('http')
8+
const https = require('https')
89

910
/**
1011
* Cleans up a file write stream (ends stream, deletes the file).
@@ -42,6 +43,7 @@ function copy (copyToPath, copyFromUri, callback) {
4243
debug.handlers('COPY -- Wrote data to: ' + copyToPath)
4344
callback()
4445
})
46+
const request = /^https:/.test(copyFromUri) ? https : http
4547
request.get(copyFromUri)
4648
.on('error', function (err) {
4749
debug.handlers('COPY -- Error requesting source file: ' + err)
@@ -59,7 +61,7 @@ function copy (copyToPath, copyFromUri, callback) {
5961
error.statusCode = response.statusCode
6062
return callback(error)
6163
}
64+
response.pipe(destinationStream)
6265
})
63-
.pipe(destinationStream)
6466
})
6567
}

0 commit comments

Comments
 (0)