Calculate HTTPS POST Request size

99封情书 提交于 2019-12-25 08:29:57

问题


I have a middlet that sends data to a servlet.

Anyone knows how can I calculate the size of request of the middlet in a servlet?

I'm tring to sum of request header + request size + certificate size Is it correct?

With this I'm trying to recreate the request:

http://wikis.sun.com/display/WebServerdocs/Analyzing+SSL+Requests+and+Responses


回答1:


I'm pretty sure that there is no simple way.

In fact, I'm not even sure this is a meaningful thing to measure. The request header and body are part of the HTTP application protocol. The certificate is sent as part of SSL / TLS setup ... before the HTTP stuff starts. And once SSL / TLS has started, the HTTP protocol is run "on top of" the SSL / TLS channel.

Even just measuring the amount of data in a HTTP request is tricky. A typical HTTP stack does not assemble the entire request message in one place, and does not keep a running total of the amount of data sent. Depending on the HTTP stack that you are using, you could (in theory) arrange to use a custom socket factory and socket streams that count the bytes sent.




回答2:


Read more about SSL handshake:

I think the conversation round-trip may worry you as well as packet sizes.

Once handshake phase is finished and connection is reused (keepalive) only HTTP data is sent, encrypted of course.




回答3:


like this:

$value) { $size += (strlen($key) + strlen($value) + 3); } printf("size=%d",$size); exit; ?>


来源:https://stackoverflow.com/questions/4434476/calculate-https-post-request-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!