[問題] 如何從Java程式中得知傳輸量?
我想知道一個HTTP Request送出後,Response總共回傳幾Bytes的資料
看Response的Header "Content-Length: 3892"似乎只有文字內容的大小
用Wireshark看到一個Reassembled Tcp Segments (4058 bytes)
似乎是包含Header和Content-Length的大小
然後最開頭的 Frame 688 (1244 bytes on wire, 1244 bytes captured)
http://mpc.cs.nctu.edu.tw/~cltsai/response.png

不知道要不要算進去,如果算進去那這個回傳就用了 4058+1244 bytes的流量
但那個1244不知道如何取得,
我現在是用Content-Length加Response Header大小來當傳輸量,程式如下
for (int i = 0; i < httpResponse.getAllHeaders().length; i++) {
sum += httpResponse.getAllHeaders()[i].toString().length();
}
total = Integer.parseInt(
httpResponse.getLastHeader("Content-Length").toString()) + sum;
請問各位大大有其他方法嗎?謝謝!
--
☆
╭──╮╭──╮┌╭─╮ ○ ┌┐┌┐╭──╮┌┐┌┐ ○ ┌╭─╮╭──┐
│╭─┘│╭╮││╭╮│ ┌┐ │││││╭─╯│╰╭╯ ┌┐ │╭╮││╭╮│
│┌┐││┌─╯││││ ││ │╰┘│╰─╮╮│╭╮╮ ││ ││││╰─┐│
╰──╯╰──╯└┘└┘ └┘ ╰─└┘╰──╯└┘└┘ └┘ └┘└┘╰──╯
http://www.wretch.cc/blog/Geniusking ☆
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.198.7
→
07/25 21:09, , 1F
07/25 21:09, 1F
→
07/25 22:39, , 2F
07/25 22:39, 2F
→
07/26 11:52, , 3F
07/26 11:52, 3F
→
07/26 16:13, , 4F
07/26 16:13, 4F