How do I get the total byte transferred over the libcurl connection?

Libcurl allows you to get information about how many byte protocol layer protocols (HTTP, FTP, etc.) are sent and received. However, is there a way to get the number of bytes the underlying socket is sending and receiving? I'm talking about all the data, including for example bytes, that the socket uses to establish an SSL connection. So I'm basically looking for a way to get the same information from libcurl that the Apache HTTP client gives in HttpConnectionMetrics.getSentBytesCount()

and out HttpConnectionMetrics.getReceivedBytesCount()

. One idea is to access the juice, which Libcurl uses directly from C ++; however, how to calculate the total socket bytes sent / received?

+3


source to share


1 answer


Use CURLOPT_DEBUGFUNCTION and just add different parts as they show the number of socket levels. So this will give you the exact number for all plain text protocols, the ones that don't use SSL



However - this will not necessarily give you counters for the SSL layer, although in the case of HTTPS / FTPS, etc., since libcurl does not always reveal this. It depends on which specific TLS server was built to use. The OpenSSL backend needs to be accurate and it will also tell you about incoming and outgoing TLS data (using the same debug callback).

+2


source







All Articles