Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Node.js http.ClientRequest.writableEnded API

  • Last Updated : 13 Oct, 2021

The http.ClientRequest.writableEnded is an inbuilt application programming interface of class ClientRequest within http module which is used to check if the request.end() has been called or not.


const request.writableEnded

Parameters: This API does not accept any argument as parameter.

Return Value : This method returns true if and only if the request.end() has been called.

Example 1:


// Node.js program to demonstrate the  
// request.writableEnded APi
// Importing http module
const http = require('http');
// Create an HTTP server
const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
// Now that server is running
server.listen(3000, '', () => {
  // make a request
  const options = {
    port: 3000,
    host: '',
    headers: {
      'Connection': 'Upgrade',
      'Upgrade': 'websocket'
  // getting client request
  const req = http.request(options);
  // checking if the request.end() has been called
  // by using writableEnded api
  console.log('request.end() has been called')
  console.log('request.end() has not been called')


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!