2011-01-25 4 views
0

파일 업로드 중에 업로드 길이가 구성된 maxRequestLength를 초과 할 때 IIS에서 현재 실행중인 요청에 실제로 어떤 일이 발생합니다. 괜찮은 기사를 찾기 위해 열심히 노력했지만 아무도 없습니다! 클래스 HttpRequest에서 및 방법 GetEntireRawContent에서maxRequestLength - 장면 세부 정보가 필요합니다!

이 조건이 점검되고 예외가 발생합니다 :이 정확히 무슨이다

감사

+0

yo 정확하게 무슨 일이 일어날까요? 정확히 무엇이 발생하는지 예외가 throw됩니다. –

답변

2

여기

if (length > maxRequestLengthBytes) 
{ 
    throw new HttpException(System.Web.SR.GetString("Max_request_length_exceeded"), null, 0xbbc); 
} 

는 방법의 전부입니다 유용하다고 생각되는 경우 :

private HttpRawUploadedContent GetEntireRawContent() 
    { 
     if (this._wr == null) 
     { 
      return null; 
     } 
     if (this._rawContent == null) 
     { 
      HttpRuntimeSection httpRuntime = RuntimeConfig.GetConfig(this._context).HttpRuntime; 
      int maxRequestLengthBytes = httpRuntime.MaxRequestLengthBytes; 
      if (this.ContentLength > maxRequestLengthBytes) 
      { 
       if (!(this._wr is IIS7WorkerRequest)) 
       { 
        this.Response.CloseConnectionAfterError(); 
       } 
       throw new HttpException(System.Web.SR.GetString("Max_request_length_exceeded"), null, 0xbbc); 
      } 
      int requestLengthDiskThresholdBytes = httpRuntime.RequestLengthDiskThresholdBytes; 
      HttpRawUploadedContent data = new HttpRawUploadedContent(requestLengthDiskThresholdBytes, this.ContentLength); 
      byte[] preloadedEntityBody = this._wr.GetPreloadedEntityBody(); 
      if (preloadedEntityBody != null) 
      { 
       this._wr.UpdateRequestCounters(preloadedEntityBody.Length); 
       data.AddBytes(preloadedEntityBody, 0, preloadedEntityBody.Length); 
      } 
      if (!this._wr.IsEntireEntityBodyIsPreloaded()) 
      { 
       int num3 = (this.ContentLength > 0) ? (this.ContentLength - data.Length) : 0x7fffffff; 
       HttpApplication applicationInstance = this._context.ApplicationInstance; 
       byte[] buffer = (applicationInstance != null) ? applicationInstance.EntityBuffer : new byte[0x2000]; 
       int length = data.Length; 
       while (num3 > 0) 
       { 
        int size = buffer.Length; 
        if (size > num3) 
        { 
         size = num3; 
        } 
        int bytesIn = this._wr.ReadEntityBody(buffer, size); 
        if (bytesIn <= 0) 
        { 
         break; 
        } 
        this._wr.UpdateRequestCounters(bytesIn); 
        this.NeedToInsertEntityBody = true; 
        data.AddBytes(buffer, 0, bytesIn); 
        num3 -= bytesIn; 
        length += bytesIn; 
        if (length > maxRequestLengthBytes) 
        { 
         throw new HttpException(System.Web.SR.GetString("Max_request_length_exceeded"), null, 0xbbc); 
        } 
       } 
      } 
      data.DoneAddingBytes(); 
      if ((this._installedFilter != null) && (data.Length > 0)) 
      { 
       try 
       { 
        try 
        { 
         this._filterSource.SetContent(data); 
         HttpRawUploadedContent content2 = new HttpRawUploadedContent(requestLengthDiskThresholdBytes, data.Length); 
         HttpApplication application2 = this._context.ApplicationInstance; 
         byte[] buffer3 = (application2 != null) ? application2.EntityBuffer : new byte[0x2000]; 
         while (true) 
         { 
          int num7 = this._installedFilter.Read(buffer3, 0, buffer3.Length); 
          if (num7 == 0) 
          { 
           break; 
          } 
          content2.AddBytes(buffer3, 0, num7); 
         } 
         content2.DoneAddingBytes(); 
         data = content2; 
        } 
        finally 
        { 
         this._filterSource.SetContent(null); 
        } 
       } 
       catch 
       { 
        throw; 
       } 
      } 
      this._rawContent = data; 
     } 
     return this._rawContent; 
    } 
+0

왜 applicationInstance.EntityBuffer를 사용하여 ReadEntityBody의 읽기를 버퍼링합니까? 스레딩 문제가 발생하지 않을까요? 또는 IIS가 이러한 요청을 순차적으로 처리합니까? – Triynko

관련 문제