mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
1563088f06
In the spec, a URL record has an associated "blob URL entry", which for `blob:` URLs is populated during parsing to contain a reference to the `Blob` object that backs that object URL. It is this blob URL entry that the `fetch` API uses to resolve an object URL. Therefore, since the `Request` constructor parses URL inputs, it will have an associated blob URL entry which will be used when fetching, even if the object URL has been revoked since the construction of the `Request` object. (The `Request` constructor takes the URL as a string and parses it, so the object URL must be live at the time it is called.) This PR adds a new `blobFromObjectUrl` JS function (backed by a new `op_blob_from_object_url` op) that, if the URL is a valid object URL, returns a new `Blob` object whose parts are references to the same Rust `BlobPart`s used by the original `Blob` object. It uses this function to add a new `blobUrlEntry` field to inner requests, which will be `null` or such a `Blob`, and then uses `Blob.prototype.stream()` as the response's body. As a result of this, the `blob:` URL resolution from `op_fetch` is now useless, and has been removed.
102 lines
2.8 KiB
TypeScript
102 lines
2.8 KiB
TypeScript
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
|
|
|
/// <reference no-default-lib="true" />
|
|
/// <reference lib="esnext" />
|
|
|
|
declare namespace globalThis {
|
|
declare namespace __bootstrap {
|
|
declare var infra: {
|
|
collectSequenceOfCodepoints(
|
|
input: string,
|
|
position: number,
|
|
condition: (char: string) => boolean,
|
|
): {
|
|
result: string;
|
|
position: number;
|
|
};
|
|
ASCII_DIGIT: string[];
|
|
ASCII_UPPER_ALPHA: string[];
|
|
ASCII_LOWER_ALPHA: string[];
|
|
ASCII_ALPHA: string[];
|
|
ASCII_ALPHANUMERIC: string[];
|
|
HTTP_TAB_OR_SPACE: string[];
|
|
HTTP_WHITESPACE: string[];
|
|
HTTP_TOKEN_CODE_POINT: string[];
|
|
HTTP_TOKEN_CODE_POINT_RE: RegExp;
|
|
HTTP_QUOTED_STRING_TOKEN_POINT: string[];
|
|
HTTP_QUOTED_STRING_TOKEN_POINT_RE: RegExp;
|
|
HTTP_TAB_OR_SPACE_PREFIX_RE: RegExp;
|
|
HTTP_TAB_OR_SPACE_SUFFIX_RE: RegExp;
|
|
HTTP_WHITESPACE_PREFIX_RE: RegExp;
|
|
HTTP_WHITESPACE_SUFFIX_RE: RegExp;
|
|
regexMatcher(chars: string[]): string;
|
|
byteUpperCase(s: string): string;
|
|
byteLowerCase(s: string): string;
|
|
collectHttpQuotedString(
|
|
input: string,
|
|
position: number,
|
|
extractValue: boolean,
|
|
): {
|
|
result: string;
|
|
position: number;
|
|
};
|
|
forgivingBase64Encode(data: Uint8Array): string;
|
|
forgivingBase64Decode(data: string): Uint8Array;
|
|
};
|
|
|
|
declare var domException: {
|
|
DOMException: typeof DOMException;
|
|
};
|
|
|
|
declare namespace mimesniff {
|
|
declare interface MimeType {
|
|
type: string;
|
|
subtype: string;
|
|
parameters: Map<string, string>;
|
|
}
|
|
declare function parseMimeType(input: string): MimeType | null;
|
|
declare function essence(mimeType: MimeType): string;
|
|
declare function serializeMimeType(mimeType: MimeType): string;
|
|
}
|
|
|
|
declare var eventTarget: {
|
|
EventTarget: typeof EventTarget;
|
|
};
|
|
|
|
declare var location: {
|
|
getLocationHref(): string | undefined;
|
|
};
|
|
|
|
declare var base64: {
|
|
atob(data: string): string;
|
|
btoa(data: string): string;
|
|
};
|
|
|
|
declare var file: {
|
|
blobFromObjectUrl(url: string): Blob | null;
|
|
getParts(blob: Blob): string[];
|
|
Blob: typeof Blob;
|
|
File: typeof File;
|
|
};
|
|
|
|
declare var streams: {
|
|
ReadableStream: typeof ReadableStream;
|
|
isReadableStreamDisturbed(stream: ReadableStream): boolean;
|
|
createProxy<T>(stream: ReadableStream<T>): ReadableStream<T>;
|
|
};
|
|
|
|
declare namespace messagePort {
|
|
declare type Transferable = {
|
|
kind: "messagePort";
|
|
data: number;
|
|
} | {
|
|
kind: "arrayBuffer";
|
|
data: number;
|
|
};
|
|
declare interface MessageData {
|
|
data: Uint8Array;
|
|
transferables: Transferable[];
|
|
}
|
|
}
|
|
}
|
|
}
|