HttpResponseLenght Header Java Servlet Content

What happens if I do not specify the contentLenght header when sending an HttpResponse containing a zip file.

I did some tests and it seems that the header is set by default with the correct file length. Can I be sure that this always happens. When can I find the documentation?

this is the most important part of the code:

    response.setContentType("application/zip");
            response.addHeader("Content-disposition", "attachment; filename=" + zipFileName);
        zos.close();
        out.close();
        response.flushBuffer(); 

Davide

+1
source share
1 answer

, 2 ( make/version/config), . , , , , , chunked encoding .

, , javadoc HttpServlet#doGet(), :

...

Content-Length ( ServletResponse.setContentLength(int)), , . , .

HTTP 1.1 ( , Transfer-Encoding), Content-Length.

...

"" .

actualContent

,

part1LengthInHexadecimal
actualPart1Content

part2LengthInHexadecimal
actualPart2Content

part3LengthInHexadecimal
actualPart3Content

0

, (, "" ). , .

. wikipedia.

+2

Source: https://habr.com/ru/post/1598277/


All Articles