lib/collection/request.js
function () {
        var contentLength = this.headers.get(CONTENT_LENGTH),
            requestTarget = this.url.getPathWithQuery(),
            bodyString,
            sizeInfo = {
                body: 0,
                header: 0,
                total: 0,
                source: SIZE_SOURCE.computed
            };

        // if 'Content-Length' header is present, we take body as declared by
        // the client(postman-request or user-defined). else we need to compute the same.
        if (contentLength && util.isNumeric(contentLength)) {
            sizeInfo.body = parseInt(contentLength, 10);
            sizeInfo.source = SIZE_SOURCE.contentLength;
        }
        // otherwise, if body is defined, we calculate the length of the body
        else if (this.body) {
            // @note body.toString() returns E for formdata or file mode
            bodyString = this.body.toString();
            sizeInfo.body = supportsBuffer ? Buffer.byteLength(bodyString) : bodyString.length;
        }

        // https://tools.ietf.org/html/rfc7230#section-3
        // HTTP-message   = start-line (request-line / status-line)
        //                  *( header-field CRLF )
        //                  CRLF
        //                  [ message-body ]
        // request-line = method SP request-target SP HTTP-version CRLF
        sizeInfo.header = (this.method + SP + requestTarget + SP + HTTP_X_X + CRLF + CRLF).length +
            this.headers.contentSize();

        // compute the approximate total body size by adding size of header and body
        sizeInfo.total = (sizeInfo.body || 0) + (sizeInfo.header || 0);
        return sizeInfo;
    }
function () {
        var contentLength = this.headers.get(CONTENT_LENGTH),
            requestTarget = this.url.getPathWithQuery(),
            bodyString,
            sizeInfo = {
                body: 0,
                header: 0,
                total: 0,
                source: SIZE_SOURCE.computed
            };

        // if 'Content-Length' header is present, we take body as declared by
        // the client(postman-request or user-defined). else we need to compute the same.
        if (contentLength && util.isNumeric(contentLength)) {
            sizeInfo.body = parseInt(contentLength, 10);
            sizeInfo.source = SIZE_SOURCE.contentLength;
        }
        // otherwise, if body is defined, we calculate the length of the body
        else if (this.body) {
            // @note body.toString() returns E for formdata or file mode
            bodyString = this.body.toString();
            sizeInfo.body = supportsBuffer ? Buffer.byteLength(bodyString) : bodyString.length;
        }

        // https://tools.ietf.org/html/rfc7230#section-3
        // HTTP-message   = start-line (request-line / status-line)
        //                  *( header-field CRLF )
        //                  CRLF
        //                  [ message-body ]
        // request-line = method SP request-target SP HTTP-version CRLF
        sizeInfo.header = (this.method + SP + requestTarget + SP + HTTP_X_X + CRLF + CRLF).length +
            this.headers.contentSize();

        // compute the approximate total body size by adding size of header and body
        sizeInfo.total = (sizeInfo.body || 0) + (sizeInfo.header || 0);
        return sizeInfo;
    }
function ( ) { var contentLength = this . headers . get ( CONTENT_LENGTH ) , requestTarget = this . url . getPathWithQuery ( ) , bodyString , sizeInfo = { body : 0 , header : 0 , total : 0 , source : SIZE_SOURCE . computed } ; // if 'Content-Length' header is present, we take body as declared by // the client(postman-request or user-defined). else we need to compute the same. if ( contentLength && util . isNumeric ( contentLength ) ) { sizeInfo . body = parseInt ( contentLength , 10 ) ; sizeInfo . source = SIZE_SOURCE . contentLength ; } // otherwise, if body is defined, we calculate the length of the body else if ( this . body ) { // @note body.toString() returns E for formdata or file mode bodyString = this . body . toString ( ) ; sizeInfo . body = supportsBuffer ? Buffer . byteLength ( bodyString ) : bodyString . length ; } // https://tools.ietf.org/html/rfc7230#section-3 // HTTP-message   = start-line (request-line / status-line) //                  *( header-field CRLF ) //                  CRLF //                  [ message-body ] // request-line = method SP request-target SP HTTP-version CRLF sizeInfo . header = ( this . method + SP + requestTarget + SP + HTTP_X_X + CRLF + CRLF ) . length + this . headers . contentSize ( ) ; // compute the approximate total body size by adding size of header and body sizeInfo . total = ( sizeInfo . body || 0 ) + ( sizeInfo . header || 0 ) ; return sizeInfo ; }
Get the request size by computing the headers and body or using the
actual content length header once the request is sent.

@returns {Object}
Get the request size by computing the headers and body or using the actual content length header once the request is sent .