问题
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