justcoding121 / titanium-web-proxy

A cross-platform asynchronous HTTP(S) proxy server in C#.
MIT License
1.93k stars 618 forks source link

Large file download issue from drive over titanium-web-proxy #911

Open testuser546 opened 2 years ago

testuser546 commented 2 years ago

I am facing issue in downloading big files like above 100mb. If I tried to download such files chrome starts download but does not show any downloading or failed status. Even I did not see any file in download folder. though I tried debugging through titanium code, It does download data ,and in response data is not in chunks. here i do get content length as 197000000. await WebSession.ServerConnection.StreamReader.CopyBytesToStream(responseBodyStream, WebSession.Response.ContentLength); I have also gone through "CopyBytesToStream" this method

 internal static async Task CopyBytesToStream(this CustomBinaryReader streamReader, Stream stream, long totalBytesToRead)
        {         
            var buffer = streamReader.Buffer;
            long remainingBytes = totalBytesToRead;
            while (remainingBytes > 0)
            {   int bytesToRead = buffer.Length;
                if (remainingBytes < bytesToRead)
                {   bytesToRead = (int)remainingBytes;
                }
                int bytesRead = await streamReader.ReadBytesAsync(buffer, bytesToRead);
                if (bytesRead == 0)
                {    break;     }
                remainingBytes -= bytesRead;
                await stream.WriteAsync(buffer, 0, bytesRead);
            }
        }

and it takes time as default "streamReader" size is 8192. it keeps looping until complete download. but till the time browser either gave message that "You are offline some functionality may not work" or just nothing like it doesn't care. I'm not understanding where the data goes or why file is not created there in downloads and why chrome behaves like this. can any one help me to overcome from this issue. it only happens if traffic goes through titanium proxy.

zeltrax00 commented 1 year ago

do you solve the issue or find an alternative solution ?