android - Calculating http overhead and headers -
i wondering if provide me on calculating overhead when requesting data via androidhttpclient get/post requests.
why ask? developed app shows different traffic usage when calculating payload , internet provider stats. put, data sent/received app 6mb, provider shows 16. that's > 200%.
since communication done via 1 function, can track payload size, , additional size must overhead. big, or i'm missing something? here function:
public byte[] get(final string url, int timeout) throws clientprotocolexception, ioexception { uri uri; try { uri = new uri(url); } catch (urisyntaxexception e) { lasterror = error_url; e.printstacktrace(); return null; } out += uri.tostring().length(); final httpget = new httpget(uri); httpconnectionparams.setsotimeout(httpparameters, timeout); httpconnectionparams.setconnectiontimeout(httpparameters, timeout); get.setparams(httpparameters); httpresponse responce; final long st = system.currenttimemillis(); responce = client.execute(get, localcontext); ping = (int) (system.currenttimemillis() - st); inputstream = responce.getentity().getcontent(); byte[] data = inputstreamtobytearray(is); responce.getentity().consumecontent(); in += data.length; lasterror = error_success; return data; }
ipoverhead = 26 bytes; tcpoverhead = 20 bytes;
and http comes in, how measure it's overhead?
any ideas?
http's overhead made of status line + headers.
using android's apache httpresponse
allows 1 status line , headers (using getstatusline
, getallheaders()
, in parsed way, not in raw text. status line , headers uniformly defined (by rfc2616 §6.1 , §4.2 respectively), may have arbitrary number of (non-parsed) whitespace, can roughly determine overhead here.
unless using api or raw android sockets (which require implement own http handling), you're half there.
Comments
Post a Comment