@azure/functions
Version:
Microsoft Azure Functions NodeJS Framework
65 lines (50 loc) • 1.83 kB
text/typescript
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.
import * as types from '@azure/functions';
import { HttpResponseInit } from '@azure/functions';
import { Blob } from 'buffer';
import { ReadableStream } from 'stream/web';
import { FormData, Headers, Response as uResponse, ResponseInit as uResponseInit } from 'undici';
import { isDefined } from '../utils/nonNull';
export class HttpResponse implements types.HttpResponse {
readonly cookies: types.Cookie[];
readonly enableContentNegotiation: boolean;
constructor(resInit?: HttpResponseInit) {
const uResInit: uResponseInit = { status: resInit?.status, headers: resInit?.headers };
if (isDefined(resInit?.jsonBody)) {
this.
} else {
this.
}
this.cookies = resInit?.cookies || [];
this.enableContentNegotiation = !!resInit?.enableContentNegotiation;
}
get status(): number {
return this.
}
get headers(): Headers {
return this.
}
get body(): ReadableStream<any> | null {
return this.
}
get bodyUsed(): boolean {
return this.
}
async arrayBuffer(): Promise<ArrayBuffer> {
return this.
}
async blob(): Promise<Blob> {
return this.
}
async formData(): Promise<FormData> {
return this.
}
async json(): Promise<unknown> {
return this.
}
async text(): Promise<string> {
return this.
}
}