Executing code like this when netfox is active causes several bad things to happen:
1) The request never completes (times out)
2) iOS allocates a crazy amount of memory, with hundred of thousands of CTHTTPMessage and HTTP2StreamBridge objects being allocated by CFNetwork (see screenshot from the debug memory graph in Xcode)
(Of course, neither of these things happens when netfox is not active)
I've tracked this issue to the getNFXBody() method in NFXHelper.swift and the readfully() method; specifically, this line:
calls readfully(), which proceeds to read the contents of the httpBodyStream object. Note that calling read() on httpBodyStream is discouraged by Apple's docs on the httpBodyStream object, which say:
The stream is returned for examination only; it’s unsafe for the caller to manipulate the stream in any way.
Modifying readfully() to simply return an empty data object makes this issue go away.
We have an app that uploads a file via a POST request by doing something like:
Executing code like this when netfox is active causes several bad things to happen:
1) The request never completes (times out) 2) iOS allocates a crazy amount of memory, with hundred of thousands of CTHTTPMessage and HTTP2StreamBridge objects being allocated by CFNetwork (see screenshot from the debug memory graph in Xcode)
(Of course, neither of these things happens when netfox is not active)
I've tracked this issue to the getNFXBody() method in NFXHelper.swift and the readfully() method; specifically, this line:
return httpBodyStream?.readfully() ?? URLProtocol.property(forKey: "NFXBodyData", in: self) as? Data ?? Data()
calls readfully(), which proceeds to read the contents of the httpBodyStream object. Note that calling read() on httpBodyStream is discouraged by Apple's docs on the httpBodyStream object, which say:
Modifying readfully() to simply return an empty data object makes this issue go away.