Set length on cURL write

This commit is contained in:
Joshua Granick
2019-02-06 11:38:50 -08:00
parent f37ba6f3d2
commit 864dcf74cc
2 changed files with 8 additions and 4 deletions

View File

@@ -611,7 +611,7 @@ namespace lime {
value _bytes = bytes->Value ((value)bytesRoot->Get ());
curl_gc_mutex.Unlock ();
length = val_int ((value)writeCallback->Call (_bytes));
length = val_int ((value)writeCallback->Call (_bytes, alloc_int (position)));
curl_gc_mutex.Lock ();
if (length == CURL_WRITEFUNC_PAUSE) {
@@ -715,7 +715,7 @@ namespace lime {
writeBufferPosition[easy_handle] = 0;
curl_gc_mutex.Unlock ();
length = *((int*)writeCallback->Call (bytes));
length = *((int*)writeCallback->Call (bytes, &position));
curl_gc_mutex.Lock ();
if (length == CURL_WRITEFUNC_PAUSE) {

View File

@@ -203,9 +203,13 @@ class CURL {
case CURLOption.WRITEFUNCTION:
var callback:CURL->Bytes->Int = cast parameter;
parameter = function (bytes:Bytes) {
parameter = function (bytes:Bytes, length:Int) {
return callback (this, bytes);
var cacheLength = bytes.length;
@:privateAccess bytes.length = length;
var read = callback (this, bytes);
@:privateAccess bytes.length = cacheLength;
return read;
}