(body = null, options = {})
| 21 | */ |
| 22 | export default class Response extends Body { |
| 23 | constructor(body = null, options = {}) { |
| 24 | super(body, options); |
| 25 | |
| 26 | // eslint-disable-next-line no-eq-null, eqeqeq, no-negated-condition |
| 27 | const status = options.status != null ? options.status : 200; |
| 28 | |
| 29 | const headers = new Headers(options.headers); |
| 30 | |
| 31 | if (body !== null && !headers.has('Content-Type')) { |
| 32 | const contentType = extractContentType(body, this); |
| 33 | if (contentType) { |
| 34 | headers.append('Content-Type', contentType); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | this[INTERNALS] = { |
| 39 | type: 'default', |
| 40 | url: options.url, |
| 41 | status, |
| 42 | statusText: options.statusText || '', |
| 43 | headers, |
| 44 | counter: options.counter, |
| 45 | highWaterMark: options.highWaterMark |
| 46 | }; |
| 47 | } |
| 48 | |
| 49 | get type() { |
| 50 | return this[INTERNALS].type; |
nothing calls this directly
no test coverage detected