Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/functions",
"version": "4.11.1",
"version": "4.11.2",
"description": "Microsoft Azure Functions NodeJS Framework",
"keywords": [
"azure",
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

export const version = '4.11.1';
export const version = '4.11.2';

export const returnBindingKey = '$return';
34 changes: 34 additions & 0 deletions test/http/HttpResponse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Blob } from 'buffer';
import * as chai from 'chai';
import { expect } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import { Readable } from 'stream';
import { ReadableStream } from 'stream/web';
import { HttpResponse } from '../../src/http/HttpResponse';

Expand Down Expand Up @@ -366,6 +367,39 @@ describe('HttpResponse', () => {
});
expect(await res.text()).to.equal('Stream content');
});

it('Node.js Readable stream body', async () => {
// Create a Node.js Readable stream (common for HTTP streaming scenarios)
const readable = new Readable({
read() {
this.push('Readable ');
this.push('stream ');
this.push('content');
this.push(null); // Signal end of stream
},
});

const res = new HttpResponse({
body: readable,
});
expect(await res.text()).to.equal('Readable stream content');
});

it('Node.js Readable stream from async generator', async () => {
// Common pattern for HTTP streaming (e.g., AI chat responses)
function* generateChunks() {
yield 'Hello ';
yield 'from ';
yield 'stream';
}

const readable = Readable.from(generateChunks());

const res = new HttpResponse({
body: readable,
});
expect(await res.text()).to.equal('Hello from stream');
});
});

describe('HttpHeadersInit types', () => {
Expand Down
3 changes: 3 additions & 0 deletions types/http.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

import { Blob } from 'buffer';
import { Readable } from 'stream';
import { ReadableStream } from 'stream/web';
import { URLSearchParams } from 'url';
import { FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
Expand All @@ -11,9 +12,11 @@ import { InvocationContext } from './InvocationContext';
* Represents the body types that can be used in an HTTP response.
* This is a local definition to avoid dependency on lib.dom.
* Compatible with Node.js native Fetch API body types.
* Includes Node.js Readable streams for HTTP streaming scenarios.
*/
export type HttpResponseBodyInit =
| ReadableStream
| Readable
| Blob
| ArrayBufferView
| ArrayBuffer
Expand Down
Loading