(path, headersParam, options)
| 3136 | // headers. If statCheck returns false, the operation is aborted and no |
| 3137 | // file details are sent. |
| 3138 | respondWithFile(path, headersParam, options) { |
| 3139 | if (this.destroyed || this.closed) |
| 3140 | throw new ERR_HTTP2_INVALID_STREAM(); |
| 3141 | if (this.headersSent) |
| 3142 | throw new ERR_HTTP2_HEADERS_SENT(); |
| 3143 | |
| 3144 | assertIsObject(options, 'options'); |
| 3145 | options = { ...options }; |
| 3146 | |
| 3147 | if (options.offset !== undefined && typeof options.offset !== 'number') |
| 3148 | throw new ERR_INVALID_ARG_VALUE('options.offset', options.offset); |
| 3149 | |
| 3150 | if (options.length !== undefined && typeof options.length !== 'number') |
| 3151 | throw new ERR_INVALID_ARG_VALUE('options.length', options.length); |
| 3152 | |
| 3153 | if (options.statCheck !== undefined && |
| 3154 | typeof options.statCheck !== 'function') { |
| 3155 | throw new ERR_INVALID_ARG_VALUE('options.statCheck', options.statCheck); |
| 3156 | } |
| 3157 | |
| 3158 | let streamOptions = 0; |
| 3159 | if (options.waitForTrailers) { |
| 3160 | streamOptions |= STREAM_OPTION_GET_TRAILERS; |
| 3161 | this[kState].flags |= STREAM_FLAGS_HAS_TRAILERS; |
| 3162 | } |
| 3163 | |
| 3164 | const session = this[kSession]; |
| 3165 | debugStreamObj(this, 'initiating response from file'); |
| 3166 | this[kUpdateTimer](); |
| 3167 | this.ownsFd = true; |
| 3168 | |
| 3169 | const { |
| 3170 | headers, |
| 3171 | statusCode, |
| 3172 | } = prepareResponseHeadersObject(headersParam, options); |
| 3173 | |
| 3174 | // Payload/DATA frames are not permitted in these cases |
| 3175 | if (statusCode === HTTP_STATUS_NO_CONTENT || |
| 3176 | statusCode === HTTP_STATUS_RESET_CONTENT || |
| 3177 | statusCode === HTTP_STATUS_NOT_MODIFIED || |
| 3178 | this.headRequest) { |
| 3179 | throw new ERR_HTTP2_PAYLOAD_FORBIDDEN(statusCode); |
| 3180 | } |
| 3181 | |
| 3182 | fs.open(path, 'r', |
| 3183 | afterOpen.bind(this, session, options, headers, streamOptions)); |
| 3184 | } |
| 3185 | |
| 3186 | // Sends a block of informational headers. In theory, the HTTP/2 spec |
| 3187 | // allows sending a HEADER block at any time during a streams lifecycle, |
no test coverage detected