Heavily inspired by send (https://github.com/pillarjs/send/tree/0.17.1)

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

- BYTES_RANGE_REGEXP
- ENAMETOOLONG_REGEXP
- ENCODE_CHARS_REGEXP
- ENOENT_REGEXP
- MAX_MAXAGE
- UNMATCHED_SURROGATE_PAIR_REGEXP
- UNMATCHED_SURROGATE_PAIR_REPLACE
- UP_PATH_REGEXP

### Functions

- _send
- clearHeaders
- collapseLeadingSlashes
- containsDotFile
- contentRange
- create404Error
- decode
- encodeUrl
- hasTrailingSlash
- isCacheable
- isConditionalGET
- isPreconditionFailure
- isRangeFresh
- normalizeList
- offsetFileReader
- removeContentHeaderFields
- send
- sendError
- sendExtension
- sendFile
- sendIndex

## Variables

### Private Const BYTES_RANGE_REGEXP

BYTES_RANGE_REGEXP: RegExp = /^ *bytes=/

- Defined in home/runner/work/opine/opine/src/utils/send.ts:47

Regular expression for identifying a bytes Range header.

### Const ENAMETOOLONG_REGEXP

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

- Defined in home/runner/work/opine/opine/src/utils/send.ts:62

### 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

- Defined in home/runner/work/opine/opine/src/utils/send.ts:623

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\)/

- Defined in home/runner/work/opine/opine/src/utils/send.ts:61

### Private Const MAX_MAXAGE

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

- Defined in home/runner/work/opine/opine/src/utils/send.ts:53

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

- Defined in home/runner/work/opine/opine/src/utils/send.ts:630

RegExp to match unmatched surrogate pair.

### Private Const UNMATCHED_SURROGATE_PAIR_REPLACE

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

- Defined in home/runner/work/opine/opine/src/utils/send.ts:637

String to replace unmatched surrogate pair with.

### Private Const UP_PATH_REGEXP

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

- Defined in home/runner/work/opine/opine/src/utils/send.ts:59

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

## Functions

### _send

- _send(req: OpineRequest, res: OpineResponse, path: string, options: any, stat: Deno.FileInfo): Promise<any>

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:367

  Transfer the file at `path`.

  #### Parameters

  - ##### req: OpineRequest

  - ##### res: OpineResponse

  - ##### path: string

  - ##### options: any

  - ##### stat: Deno.FileInfo

  #### Returns Promise<any>

### Private clearHeaders

- clearHeaders(res: OpineResponse): void

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:250

  Clear all headers from a response.

  #### Parameters

  - ##### res: OpineResponse

  #### Returns void

### Private collapseLeadingSlashes

- collapseLeadingSlashes(str: string): string

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:232

  Collapse all leading slashes into a single slash

  #### Parameters

  - ##### str: string

  #### Returns string

### Private containsDotFile

- containsDotFile(parts: string[]): boolean

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:91

  Determine if path parts contain a dotfile.

  #### Parameters

  - ##### parts: string[]

  #### Returns boolean

### Private contentRange

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

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:168

  Create a Content-Range header.

  #### Parameters

  - ##### type: string

  - ##### size: number

  - ##### Optional range: any

  #### Returns string

### Private create404Error

- create404Error(): Error

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:265

  Create a 404 error.

  #### Returns Error

### Private decode

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

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:610

  decodeURIComponent.

  Allows V8 to only de-optimize this fn instead of all of send().

  #### Parameters

  - ##### path: string

  #### Returns string | -1

### encodeUrl

- encodeUrl(url: string): string

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:656

  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

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:110

  Check if the pathname ends with "/" or "\" (os dependent).

  #### Parameters

  - ##### path: string

  #### Returns boolean

### Private isCacheable

- isCacheable(statusCode: number): boolean

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:195

  Check if the request is cacheable, aka responded with 2xx or 304 (see RFC 2616 section 14.2{5,6}).

  #### Parameters

  - ##### statusCode: number

  #### Returns boolean

### Private isConditionalGET

- isConditionalGET(req: OpineRequest): boolean

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:120

  Check if this is a conditional GET request.

  #### Parameters

  - ##### req: OpineRequest

  #### Returns boolean

### Private isPreconditionFailure

- isPreconditionFailure(req: OpineRequest, res: OpineResponse): boolean

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:135

  Check if the request preconditions failed.

  #### Parameters

  - ##### req: OpineRequest

  - ##### res: OpineResponse

  #### Returns boolean

### Private isRangeFresh

- isRangeFresh(req: OpineRequest, res: OpineResponse): boolean

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:206

  Check if the range is fresh.

  #### Parameters

  - ##### req: OpineRequest

  - ##### res: OpineResponse

  #### Returns boolean

### Private normalizeList

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

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:71

  Normalize the index option into an array.

  #### Parameters

  - ##### value: false | string | string[]

  - ##### name: string

  #### Returns string[]

### Private offsetFileReader

- offsetFileReader(file: Deno.FsFile, offset: number, contentLength: number): Promise<Deno.Reader & Deno.Closer>

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:320

  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

- removeContentHeaderFields(res: OpineResponse): void

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:178

  Strip content-* header fields.

  #### Parameters

  - ##### res: OpineResponse

  #### Returns void

### send

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

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:662

  #### Type parameters

  - #### T = OpineResponse<any>

  #### Parameters

  - ##### req: OpineRequest

  - ##### res: T

  - ##### path: string

  - ##### options: any

  #### Returns Promise<T | void>

### Private sendError

- sendError(res: OpineResponse, error?: any): void

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:280

  Emit errors.

  #### Parameters

  - ##### res: OpineResponse

  - ##### Optional error: any

  #### Returns void

### sendExtension

- sendExtension(req: OpineRequest, res: OpineResponse, path: string, options: any): Promise<any>

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:530

  #### Parameters

  - ##### req: OpineRequest

  - ##### res: OpineResponse

  - ##### path: string

  - ##### options: any

  #### Returns Promise<any>

### sendFile

- sendFile(req: OpineRequest, res: OpineResponse, path: string, options: any): Promise<any>

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:561

  #### Parameters

  - ##### req: OpineRequest

  - ##### res: OpineResponse

  - ##### path: string

  - ##### options: any

  #### Returns Promise<any>

### sendIndex

- sendIndex(req: OpineRequest, res: OpineResponse, path: string, options: any, index: string[]): Promise<any>

- - Defined in home/runner/work/opine/opine/src/utils/send.ts:502

  #### Parameters

  - ##### req: OpineRequest

  - ##### res: OpineResponse

  - ##### path: string

  - ##### options: any

  - ##### index: string[]

  #### Returns Promise<any>

Generated using TypeDoc