in EMASCurl/EMASCurlProtocol.m [849:879]
static size_t read_cb(char *buffer, size_t size, size_t nitems, void *userp) {
EMASCurlProtocol *protocol = (__bridge EMASCurlProtocol *)userp;
if (!protocol || !protocol.inputStream) {
return CURL_READFUNC_ABORT;
}
if (protocol.shouldCancel) {
return CURL_READFUNC_ABORT;
}
if ([protocol.inputStream streamStatus] == NSStreamStatusNotOpen) {
[protocol.inputStream open];
}
NSInteger bytesRead = [protocol.inputStream read:(uint8_t *)buffer maxLength:size * nitems];
if (bytesRead < 0) {
return CURL_READFUNC_ABORT;
}
protocol.totalBytesSent += bytesRead;
if (protocol.uploadProgressUpdateBlock) {
protocol.uploadProgressUpdateBlock(protocol.request,
bytesRead,
protocol.totalBytesSent,
protocol.totalBytesExpected);
}
return bytesRead;
}