Skip to content

Commit 119138e

Browse files
committed
Update existing algorithm step numbers
1 parent 35722f1 commit 119138e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* index.js
44
*
55
* a request API compatible with window.fetch
6+
*
7+
* All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/.
68
*/
79

810
import Body, { writeToStream, getTotalBytes } from './body';
@@ -141,10 +143,10 @@ export default function fetch(url, opts) {
141143
, timeout: request.timeout
142144
};
143145

144-
// HTTP-network fetch step 16.1.2
146+
// HTTP-network fetch step 12.1.1.3
145147
const codings = headers.get('Content-Encoding');
146148

147-
// HTTP-network fetch step 16.1.3: handle content codings
149+
// HTTP-network fetch step 12.1.1.4: handle content codings
148150

149151
// in following scenarios we ignore compression support
150152
// 1. compression support is disabled

src/request.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* request.js
44
*
55
* Request class contains server only options
6+
*
7+
* All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/.
68
*/
79

810
import Headers from './headers.js';
@@ -151,7 +153,7 @@ export function getNodeRequestOptions(request) {
151153
const parsedURL = request[INTERNALS].parsedURL;
152154
const headers = new Headers(request[INTERNALS].headers);
153155

154-
// fetch step 3
156+
// fetch step 1.3
155157
if (!headers.has('Accept')) {
156158
headers.set('Accept', '*/*');
157159
}
@@ -165,7 +167,7 @@ export function getNodeRequestOptions(request) {
165167
throw new TypeError('Only HTTP(S) protocols are supported');
166168
}
167169

168-
// HTTP-network-or-cache fetch steps 5-9
170+
// HTTP-network-or-cache fetch steps 2.4-2.7
169171
let contentLengthValue = null;
170172
if (request.body == null && /^(POST|PUT)$/i.test(request.method)) {
171173
contentLengthValue = '0';
@@ -180,20 +182,20 @@ export function getNodeRequestOptions(request) {
180182
headers.set('Content-Length', contentLengthValue);
181183
}
182184

183-
// HTTP-network-or-cache fetch step 12
185+
// HTTP-network-or-cache fetch step 2.11
184186
if (!headers.has('User-Agent')) {
185187
headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)');
186188
}
187189

188-
// HTTP-network-or-cache fetch step 16
190+
// HTTP-network-or-cache fetch step 2.15
189191
if (request.compress) {
190192
headers.set('Accept-Encoding', 'gzip,deflate');
191193
}
192194
if (!headers.has('Connection') && !request.agent) {
193195
headers.set('Connection', 'close');
194196
}
195197

196-
// HTTP-network fetch step 4
198+
// HTTP-network fetch step 4.2
197199
// chunked encoding is handled by Node.js
198200

199201
return Object.assign({}, parsedURL, {

0 commit comments

Comments
 (0)