From 4178cee1e153f55e5c4ddf05c80316f83e68ef75 Mon Sep 17 00:00:00 2001 From: Paul Cantrell Date: Mon, 5 Oct 2015 14:15:48 -0500 Subject: [PATCH] RequestTransferMetrics docs --- Source/Networking.swift | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Source/Networking.swift b/Source/Networking.swift index e8ad0540..71b1c7e3 100644 --- a/Source/Networking.swift +++ b/Source/Networking.swift @@ -39,15 +39,26 @@ public protocol RequestNetworking /// Cancel this request, if possible. func cancel() + /// Returns raw data used for progress calculation. var transferMetrics: RequestTransferMetrics { get } } +/// Used by `NetworkingProvider` implementations to report request progress. public struct RequestTransferMetrics { - public var requestBytesSent: Int64, - requestBytesTotal: Int64?, - responseBytesReceived: Int64, - responseBytesTotal: Int64? + /// Bytes of HTTP request body sent. + public var requestBytesSent: Int64 + + /// Total size of HTTP request body. Negative or nil indicates unknown size. + /// Providers should ensure that `requestBytesSent == requestBytesTotal` when the request is complete, as this + /// allows Siesta to include response latency in its progress calculation. + public var requestBytesTotal: Int64? + + /// Bytes of HTTP response body received. + public var responseBytesReceived: Int64 + + /// Total expected size of HTTP response body. Negative or nil indicates unknown size. + public var responseBytesTotal: Int64? } /// Siesta passes this callback to a `NetworkingProvider` implementation to call when the underlying network request is complete.