Diesan Romero
Diesan Romero

Reputation: 1658

How to know the size of an HTTP request before it reaches its destination?

I am studying NodeJS and I have learned about streams and buffer. I found it very interesting because it occurred to me to use it on an HTTP server, since if a request is too big, the data can be sent little by little, especially when using the verb POST to upload big files for example. The problem is that not all data (files at this case) is very big. Is there a way to know the size of a request before it reaches its destination?

Upvotes: 1

Views: 1314

Answers (1)

jfriend00
jfriend00

Reputation: 707198

From the receiving end, you can look at the Content-Length header.

It may or may not be present, depending upon the sender. For info about that, see Is the Content-Length header required for a HTTP/1.0 response?.

Upvotes: 2

Related Questions