2011-01-25 10 views
0

アップロードの長さが設定されたmaxRequestLengthを超えると、ファイルアップロード中にIISで現在実行されているリクエストに実際に何が起こりますか? それについて話すまともな記事を見つけるのは難しいが、誰もいない!クラスHttpRequestでと方法GetEntireRawContentmaxRequestLength - 必要なシーンの詳細の後ろに!

この条件がチェックされ、例外がスローされます:これは正確に何が起こるかである

おかげ

+0

何ですか正確にはどういう意味ですか?例外がスローされるのは正確に何が起こるかです。 –

答えて

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

関連する問題