@@ -40,10 +40,11 @@ #import "OFRunLoop+Private.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" +#import "OFOutOfRangeException.h" #import "OFSetOptionFailedException.h" #import "macros.h" #import "of_asprintf.h" @@ -1553,10 +1554,25 @@ - (void)cancelAsyncRequests { [OFRunLoop OF_cancelAsyncRequestsForStream: self]; } #endif + +- (void)unreadFromBuffer: (const void*)buffer + length: (size_t)length +{ + if (length > SIZE_MAX - _readBufferLength) + @throw [OFOutOfRangeException exception]; + + _readBuffer = [self resizeMemory: _readBuffer + size: _readBufferLength + length]; + + memmove(_readBuffer + length, _readBuffer, _readBufferLength); + memcpy(_readBuffer, buffer, length); + + _readBufferLength += length; +} - (void)close { [self doesNotRecognizeSelector: _cmd]; abort();