Skip to content

Commit 880dafa

Browse files
author
Ben Stahl
committed
Use consistent names
1 parent 1d606f4 commit 880dafa

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

lib/handlers/HeadHandler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class HeadHandler extends BaseHandler {
3535
res.setHeader('Upload-Length', file.upload_length);
3636
}
3737

38-
if (file.defer_length) {
38+
if (file.upload_defer_length) {
3939
// If the size of the upload is known, the Server MUST include
4040
// the Upload-Length header in the response.
41-
res.setHeader('Upload-Defer-Length', file.defer_length);
41+
res.setHeader('Upload-Defer-Length', file.upload_defer_length);
4242
}
4343

4444
return res.end();

lib/handlers/PostHandler.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ class PostHandler extends BaseHandler {
1212
* @return {function}
1313
*/
1414
send(req, res) {
15-
const length = req.headers['upload-length'];
16-
const defer_length = req.headers['upload-defer-length'];
15+
const upload_length = req.headers['upload-length'];
16+
const upload_defer_length = req.headers['upload-defer-length'];
1717
// The request MUST include a Upload-Length or Upload-Defer-Length header
18-
if (length === undefined && defer_length === undefined) {
18+
if (upload_length === undefined && upload_defer_length === undefined) {
1919
return super.send(res, 400, {}, 'Upload-Length or Upload-Defer-Length Required');
2020
}
2121

2222
// The value MUST be a non-negative integer.
23-
if (length && (isNaN(length) || parseInt(length, 10) < 0)) {
24-
console.warn(`[PostHandler] Invalid Upload-Length: ${length}`)
23+
if (upload_length && (isNaN(upload_length) || parseInt(upload_length, 10) < 0)) {
24+
console.warn(`[PostHandler] Invalid Upload-Length: ${upload_length}`);
2525
return super.send(res, 400, {}, 'Invalid Upload-Length');
2626
}
2727

2828
// The Upload-Defer-Length value MUST be 1.
29-
if (defer_length && (isNaN(defer_length) || parseInt(defer_length, 10) !== 1)) {
30-
console.warn(`[PostHandler] Invalid Upload-Defer-Length: ${defer_length}`)
29+
if (upload_defer_length && (isNaN(upload_defer_length) || parseInt(upload_defer_length, 10) !== 1)) {
30+
console.warn(`[PostHandler] Invalid Upload-Defer-Length: ${upload_defer_length}`);
3131
return super.send(res, 400, {}, 'Invalid Upload-Defer-Length');
3232
}
3333

34-
const file = new File(length, defer_length);
34+
const file = new File(upload_length, upload_defer_length);
3535
return this.store.create(file)
3636
.then((location) => {
3737
const url = `http://${req.headers.host}${this.store.path}/${file.id}`;

lib/models/File.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ const Uid = require('./Uid');
99
*/
1010

1111
class File {
12-
constructor(upload_length, defer_length) {
13-
if (upload_length === undefined && defer_length === undefined) {
14-
throw new Error('[File] constructor must be given either a upload_length or defer_length')
12+
constructor(upload_length, upload_defer_length) {
13+
if (upload_length === undefined && upload_defer_length === undefined) {
14+
throw new Error('[File] constructor must be given either a upload_length or upload_defer_length')
1515
}
1616
this.upload_length = upload_length;
17-
this.defer_length = defer_length;
17+
this.upload_defer_length = upload_defer_length;
1818
this.id = Uid.rand();
1919
}
2020
}

0 commit comments

Comments
 (0)