Open In App
Related Articles

Node.js request.writableEnded Property

Improve Article
Save Article
Like Article

The request.writableEnded (Added in v12.9.0) property is an inbuilt property of the ‘http’ module which returns true after request.end() has been called. This property does not indicate whether the data has been flushed, for this use request.writableFinished instead. 

In order to get a response and a proper result, we need to import ‘http’ module.


const http = require('http');  



Parameters: This property does not accept any parameters.

Return Value <Boolean>: It returns true after request.end() has been called.

The below examples illustrate the use of request.writableEnded property in Node.js.

Example: Filename: index.js

// Node.js program to demonstrate the 
// request.writableEnded property 
// Using require to access http module 
const { get } = require('http'); 
// Setting host server url 
const options = { host: '' }; 
// Requesting from geeksforgeeks server 
const request = get(options); 
console.log("writableEnded:", request.writableEnded);
console.log("writableEnded:", request.writableEnded);
request.once('response', (res) => { 
    // Printing the requestrelated data 
    console.log("Status:", res.statusCode, res.statusMessage); 
    console.log("Writable:", request.socket.writable); 
    console.log("Readable:", request.socket.readable); 
    console.log("writableEnded:", request.writableEnded);
    // Printing address and port after getting response 
    console.log(`IP address of geeksforgeeks is`,
    ` ${request.socket.localAddress}.`); 
    console.log(`Its port is ${request.socket.localPort}.`); 

Run index.js file using the following command:

node index.js


writableEnded: true

writableEnded: true

Status: 301 Moved Permanently

Writable: true

Readable: true

writableEnded: true

IP address of geeksforgeeks is

Its port is 64596


Last Updated : 23 Sep, 2020
Like Article
Save Article
Similar Reads
Related Tutorials