예제 #1
0
        static BaseResponseHeader()
        {
#if NET_2_0
            HttpRuntimeSection section = WebConfigurationManager.GetWebApplicationSection("system.web/httpRuntime") as HttpRuntimeSection;
#else
            HttpRuntimeConfig section = HttpContext.GetAppConfig("system.web/httpRuntime") as HttpRuntimeConfig;
#endif
            headerCheckingEnabled = section == null || section.EnableHeaderChecking;
        }
예제 #2
0
 internal void EnsureTimeout()
 {
     // Ensure that calls to Timeout property will not go to config after this call
     if (!_timeoutSet)
     {
         HttpRuntimeConfig cfg = (HttpRuntimeConfig)GetConfig("system.web/httpRuntime");
         int s = (cfg != null) ? cfg.ExecutionTimeout : HttpRuntimeConfig.DefaultExecutionTimeout;
         _timeout    = new TimeSpan(0, 0, s);
         _timeoutSet = true;
     }
 }
예제 #3
0
 /// <summary>
 /// Creates an instance of the WebServer type.
 /// </summary>
 /// <param name="config">The configuration to use in place of that provided in the app.config file</param>
 public WebServer(ServerConfig config)
 {
     ServerConfig.SetConfig(config);
     HttpRuntimeConfig.SetConfig(new HttpRuntimeConfig());
     LoadLogProvider();
 }
예제 #4
0
        void MakeInputStream()
        {
            if (worker_request == null)
            {
                throw new HttpException("No HttpWorkerRequest");
            }

            // consider for perf:
            //    return ((ServletWorkerRequest)worker_request).InputStream();

            //
            // Use an unmanaged memory block as this might be a large
            // upload
            //
            int content_length = ContentLength;

#if NET_2_0
            HttpRuntimeSection config = (HttpRuntimeSection)WebConfigurationManager.GetSection("system.web/httpRuntime");
#else
            HttpRuntimeConfig config = (HttpRuntimeConfig)HttpContext.GetAppConfig("system.web/httpRuntime");
#endif
            if (content_length > (config.MaxRequestLength * 1024))
            {
                throw new HttpException("File exceeds httpRuntime limit");
            }

            byte[] content = new byte[content_length];
            if (content == null)
            {
                throw new HttpException(String.Format("Not enough memory to allocate {0} bytes", content_length));
            }

            int     total;
            byte [] buffer;
            buffer = worker_request.GetPreloadedEntityBody();
            if (buffer != null)
            {
                total = buffer.Length;
                if (content_length > 0)
                {
                    total = Math.Min(content_length, total);
                }
                Array.Copy(buffer, content, total);
            }
            else
            {
                total = 0;
            }

            buffer = new byte [INPUT_BUFFER_SIZE];
            while (total < content_length)
            {
                int n;
                n = worker_request.ReadEntityBody(buffer, Math.Min(content_length - total, INPUT_BUFFER_SIZE));
                if (n <= 0)
                {
                    break;
                }
                Array.Copy(buffer, 0, content, total, n);
                total += n;
            }
            if (total < content_length)
            {
                throw new HttpException(411, "The uploaded file is incomplete");
            }

            input_stream = new MemoryStream(content, 0, content.Length, false, true);

            DoFilter(buffer);
        }