<%@ Page Language="C#" AutoEventWireup="true" %>

<%

    var r = Request.QueryString.Get("r");
    var length = Request.ContentLength;
    var stream = Request.InputStream;

    var block = 1024;
    var buffer = new byte[block];
    var total = 0L;
    if (length > 0)
    {
        var remains = length;
        while (remains > 0)
        {
            var read = stream.Read(buffer, 0, block);
            if (read < 1) break;
            remains -= read;
            total += read;
        }
    }
    else
    {
        while (true)
        {
            var read = stream.Read(buffer, 0, block);
            if (read < 1) break;
            total += read;
        }
    }

    Response.ContentType = "text/plain";
    Response.Write("read = " + total.ToString());

%>