How to use the http-errors.HTTPVersionNotSupported function in http-errors

To help you get started, we’ve selected a few http-errors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github commonshost / playdoh / middleware.js View on Github external
return async function playdoh (request, response, next) {
    if (request.headers[HTTP2_HEADER_ACCEPT] !== dohMediaType) {
      return next()
    }
    if (request.httpVersionMajor < dohMinimumHttpVersionMajor) {
      return next(new HTTPVersionNotSupported())
    }

    const dnsMessage = []
    switch (request.method) {
      case HTTP2_METHOD_GET:
        const { url } = request
        const dns = new URLSearchParams(url.substr(url.indexOf('?'))).get('dns')
        if (!dns) {
          return next(new BadRequest())
        }
        let decoded
        try {
          decoded = toBuffer(dns)
        } catch (error) {
          return next(new BadRequest())
        }
github fastify / fastify-sensible / lib / httpErrors.js View on Github external
httpVersionNotSupported: function httpVersionNotSupported (message) {
    return new createError.HTTPVersionNotSupported(message)
  },