2

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

iberck
  • 2,372
  • 5
  • 31
  • 41

3 Answers3

4

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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Thank you for the response. To make the thinks more easy, how can I count the TOTAL size of the HTTP request ? .... Request header + Request size data? – iberck Dec 14 '10 at 00:05
  • @iberck - See the last paragraph. Configure your client to use a special socket factory. It is not straightforward, and doing it with HTTPS in the mix is likely to make it even more complicated. I don't know enough about Java/ME to give you a recipe. – Stephen C Dec 14 '10 at 00:11
  • I don't know how can I create a special socket factory – iberck Dec 14 '10 at 06:14
1

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.

gertas
  • 16,869
  • 1
  • 76
  • 58
-4

like this:

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