diff --git a/Sources/NetShears/Extension/URLRequest+Extension.swift b/Sources/NetShears/Extension/URLRequest+Extension.swift index 7598359..10d4f02 100644 --- a/Sources/NetShears/Extension/URLRequest+Extension.swift +++ b/Sources/NetShears/Extension/URLRequest+Extension.swift @@ -24,6 +24,7 @@ extension URLRequest { data.append(&buffer, length: length) } } + httpBodyStream.close() return data as Data } } diff --git a/Sources/NetShears/URLProtocol/NetworkLoggerUrlProtocol.swift b/Sources/NetShears/URLProtocol/NetworkLoggerUrlProtocol.swift index 5c89595..4cbe81d 100644 --- a/Sources/NetShears/URLProtocol/NetworkLoggerUrlProtocol.swift +++ b/Sources/NetShears/URLProtocol/NetworkLoggerUrlProtocol.swift @@ -72,8 +72,7 @@ class NetworkLoggerUrlProtocol: URLProtocol { /// The receiver will have either an HTTP body or an HTTP body stream only one may be set for a request. /// A HTTP body stream is preserved when copying an NSURLRequest object, /// but is lost when a request is archived using the NSCoding protocol. - // return request.httpBody ?? request.httpBodyStream?.readfully() - return nil + return request.httpBody ?? request.getHttpBodyStreamData() } deinit { diff --git a/Sources/NetShears/URLProtocol/NetwrokListenerUrlProtocol.swift b/Sources/NetShears/URLProtocol/NetwrokListenerUrlProtocol.swift index 7c4f2ed..cb86972 100644 --- a/Sources/NetShears/URLProtocol/NetwrokListenerUrlProtocol.swift +++ b/Sources/NetShears/URLProtocol/NetwrokListenerUrlProtocol.swift @@ -72,8 +72,7 @@ class NetwrokListenerUrlProtocol: URLProtocol { /// The receiver will have either an HTTP body or an HTTP body stream only one may be set for a request. /// A HTTP body stream is preserved when copying an NSURLRequest object, /// but is lost when a request is archived using the NSCoding protocol. - // return request.httpBody ?? request.httpBodyStream?.readfully() - return nil + return request.httpBody ?? request.getHttpBodyStreamData() } deinit {