+ } else if (e instanceof RouterNoPathError) {
+ handler = this.handlerNotFound.bind(this);
+ } else if (e instanceof RouterNoMethodError) {
+ if (this.intrinsicHeadMethod && req.method === 'HEAD') {
+ ({ handler, handlerArgs } = this._determineHeadHandler(req, res, ctx, pathPart));
+ } else {
+ handler = this.handlerMethodNotAllowed.bind(this);
+ }
+ } else {
+ this.logger.error(_scope, 'unexpected error', { error: e });
+ handler = this.handlerInternalServerError.bind(this);
+ }
+ }
+ return { handler, handlerArgs };
+ }
+
+
+ /**
+ * For intrinsic HEAD requests, resolve the handler to invoke.
+ * @param {http.ClientRequest} req
+ * @param {http.ServerResponse} res
+ * @param {object} ctx
+ * @param {string} pathPart
+ * @returns {object}
+ */
+ _determineHeadHandler(req, res, ctx, pathPart) {
+ const _scope = _fileScope('_determineHeadHandler');
+ let handler, handlerArgs = [];
+ try {
+ ({ handler, handlerArgs } = this.router.lookup('GET', pathPart, ctx));
+ Dingus.setHeadHandler(req, res, ctx, this.intrinsicHeadPersistBody);
+ } catch (e) {
+ if (e instanceof RouterNoMethodError) {
+ handler = this.handlerMethodNotAllowed.bind(this);