From 2f79428e34ef3696cc6a6a2409b9ee7d49d0b96b Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Tue, 1 May 2012 08:04:29 -0700 Subject: [PATCH] [Issue #323] Close existing outputStream in setOutputStream: --- AFNetworking/AFURLConnectionOperation.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 5d55ab6..ed0d42d 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -248,7 +248,11 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat - (void)setOutputStream:(NSOutputStream *)outputStream { [self willChangeValueForKey:@"outputStream"]; [outputStream retain]; - [_outputStream release]; + + if (_outputStream) { + [_outputStream close]; + [_outputStream release]; + } _outputStream = outputStream; [self didChangeValueForKey:@"outputStream"];