Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does HTTP file upload work internally in IIS?

I'd like to understand what happen under the hood when you do an web upload.

I guess one of these:

  1. The file is loaded in memory by the browser, sent to the web server buffer memory, and then the app is notified to collect it.
  2. The file is being readed by the browser and at the same time sent to the web server, that can start to save the bytes progresively.

I've tried to upload a very large file, and put a breakpoint on the frist line of the method receiving the upload. I've seen how the browser toke a lot of time loading... but the breakpoint was still not hit, and after a while the breakpoint is hit.

I want to understand this, because in the worst scenario, if I allow big uploads, they could blow up the server memory at some point.

What does happen if I upload a 2Gb file? (considering that the web server/app accepts that length) would it take 2Gb of server memory?

Cheers.

like image 416
vtortola Avatar asked Feb 04 '11 13:02

vtortola


People also ask

How are HTTP requests handled by IIS?

Protocol listeners receive protocol-specific requests, send them to IIS for processing, and then return responses to requestors. For example, when a client browser requests a Web page from the Internet, the HTTP listener, HTTP. sys, picks up the request and sends it to IIS for processing.

Which HTTP method is used for file upload?

HTTP Request action allows you to upload files on a specified service.

How do I add a file to an HTTP server?

Right-click the folder and select “Upload other file here. . .“. Browse the server for the file you want to upload. Select the file and click Open. Now, you will see the file in the folder location on the server.


1 Answers

The documentation for the HttpPostedFile class (which represents a file uploaded to the server in ASP.NET) specifies:

Files are uploaded in MIME multipart/form-data format. By default, all requests, including form fields and uploaded files, larger than 256 KB are buffered to disk, rather than held in server memory.

like image 123
Frédéric Hamidi Avatar answered Sep 27 '22 19:09

Frédéric Hamidi