How to set the content length of the request based on the content?
Ex. : POST /Display HTTP/1.0 Content-Type: application/json Content-Length: 125
{"QueryReq": { "Tid": "Tid-123456", "SessionId" : "1350711351232058820" } }
On posting this request in telnet I need to press enter many times till the content length is 125 that is empty chunks are received in the server. How can set the content length automatically based on the request content?
Set Content-Length
header
var data = querystring.stringify({
"QueryReq": { "Tid": "Tid-123456", "SessionId" : "1350711351232058820" }
});
var options = {
host: xxx,
port: xxx,
----
----
headers: {
'Content-Length': data.length
}
};