Пример #1
0
    public override byte[] GetRequestContent(long requestId)
    {
        ManualResetEvent ev = new ManualResetEvent(false);

        byte[] data = null;
        MainApp.ReadClientBody(requestId.ToPointer(), Marshal.GetFunctionPointerForDelegate(new MainApp.ReadClientBodyCallback(r =>
        {
            string file = MainApp.GetRequestBodyFileName(requestId.ToPointer());
            using (var requestBody = File.OpenRead(file))
            {
                data = new byte[requestBody.Length];
                requestBody.Read(data, 0, data.Length);
            }
            ev.Set();
        })));
        ev.WaitOne();
        return(data);
    }
Пример #2
0
    internal void ReadBodyAsync(Action finishedReading)
    {
        MainApp.ReadClientBody(this.nginx_request, Marshal.GetFunctionPointerForDelegate(new MainApp.ReadClientBodyCallback(r =>
        {
            string file = MainApp.GetRequestBodyFileName(this.nginx_request);

            /*
             *
             #if PERSIST_TEMP_FILE
             * if(File.Exists("/home/chamo/request.bin")) File.Delete("/home/chamo/request.bin");
             *
             * File.Copy(file,"/home/chamo/request.bin");
             #endif
             * MainApp.WriteNginxLog(string.Format("Temporary Filename = '{0}'",file));
             */
            requestBody = File.OpenRead(file);

            /*if(this.IsMultipart)
             *          {
             *                  string boundary = this.ContentType.Substring(this.ContentType.IndexOf("boundary"));
             *                  string boundaryValue = boundary.Split('=')[1];
             *                  MainApp.WriteNginxLog(string.Format("MultiPart Boundary is '{0}'",boundaryValue));
             *                  multiParts = MultiPartUtil.GetPartsFromBodyStream(this.PostStream,boundaryValue).ToArray();
             *                  Files = (from part in multiParts
             * let contentDisposition = part.Headers["Content-Disposition"]
             * let contentType = part.Headers["Content-Type"]
             * where contentDisposition != null && contentDisposition["filename"] != null select new HttpFile
             * {
             * FileName =contentDisposition["filename"],
             * ContentType = contentType != null ? contentType.Value : string.Empty,
             * Stream = part.Stream
             *                  }).ToArray();
             *
             *          }*/
            if (finishedReading != null)
            {
                finishedReading();
            }
        })));
    }