Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "utils/send"

send is licensed as follows:

(The MIT License)

Copyright (c) 2012 TJ Holowaychuk Copyright (c) 2014-2016 Douglas Christopher Wilson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Variables

Private Const BYTES_RANGE_REGEXP

BYTES_RANGE_REGEXP: RegExp = /^ *bytes=/

Regular expression for identifying a bytes Range header.

Const ENAMETOOLONG_REGEXP

ENAMETOOLONG_REGEXP: RegExp = /\(os error 63\)|\(os error 36\)|\(os error 123\)/

Private Const ENCODE_CHARS_REGEXP

ENCODE_CHARS_REGEXP: RegExp = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g

RegExp to match non-URL code points, after encoding (i.e. not including "%") and including invalid escape sequences.

Const ENOENT_REGEXP

ENOENT_REGEXP: RegExp = /\(os error 2\)/

Private Const MAX_MAXAGE

MAX_MAXAGE: number = 60 * 60 * 24 * 365 * 1000

Maximum value allowed for the max age.

Private Const UNMATCHED_SURROGATE_PAIR_REGEXP

UNMATCHED_SURROGATE_PAIR_REGEXP: RegExp = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g

RegExp to match unmatched surrogate pair.

Private Const UNMATCHED_SURROGATE_PAIR_REPLACE

UNMATCHED_SURROGATE_PAIR_REPLACE: "$1�$2" = "$1�$2"

String to replace unmatched surrogate pair with.

Private Const UP_PATH_REGEXP

UP_PATH_REGEXP: RegExp = /(?:^|[\\/])\.\.(?:[\\/]|$)/

Regular expression to match a path with a directory up component.

Functions

_send

Private clearHeaders

Private collapseLeadingSlashes

  • collapseLeadingSlashes(str: string): string

Private containsDotFile

  • containsDotFile(parts: string[]): boolean

Private contentRange

  • contentRange(type: string, size: number, range?: any): string

Private create404Error

  • create404Error(): Error

Private decode

  • decode(path: string): string | -1

encodeUrl

  • encodeUrl(url: string): string
  • Encode a URL to a percent-encoded form, excluding already-encoded sequences.

    This function will take an already-encoded URL and encode all the non-URL code points. This function will not encode the "%" character unless it is not part of a valid sequence (%20 will be left as-is, but %foo will be encoded as %25foo).

    This encode is meant to be "safe" and does not throw errors. It will try as hard as it can to properly encode the given URL, including replacing any raw, unpaired surrogate pairs with the Unicode replacement character prior to encoding.

    Parameters

    • url: string

    Returns string

Private hasTrailingSlash

  • hasTrailingSlash(path: string): boolean

Private isCacheable

  • isCacheable(statusCode: number): boolean

Private isConditionalGET

Private isPreconditionFailure

Private isRangeFresh

Private normalizeList

  • normalizeList(value: false | string | string[], name: string): string[]

Private offsetFileReader

  • offsetFileReader(file: Deno.FsFile, offset: number, contentLength: number): Promise<Deno.Reader & Deno.Closer>
  • Sets the read offset of the provided file and returns a Deno.Reader & Deno.Closer to read the file from the offset until the provided contentLength;

    Parameters

    • file: Deno.FsFile
    • offset: number
    • contentLength: number

    Returns Promise<Deno.Reader & Deno.Closer>

    reader closer

Private removeContentHeaderFields

send

  • send<T>(req: OpineRequest, res: T, path: string, options: any): Promise<T | void>

Private sendError

sendExtension

sendFile

sendIndex

Generated using TypeDoc