Start a new topic

Content-Length response header

Hello, i want to ask if it is possible and how to get the content-length response headers from my ajax get request for example ?
1 Comment

Hi Ivan,

responses are sent with Transfer-Encoding: chunked header indicating that data is sent in a series of chunks and therefore Content-lenght header is not sent at all - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding#Directives


Since the request body is JSON, you may stringify the body and get its length. If the JSON contains only ASCII characters (1 character is 1 byte), then the stringified length would correctly represent the content length.


Let me know if this has helped.


1 person likes this
Login or Signup to post a comment