From: Martin Pirker Date: 2004-03-16T12:19:45+09:00 Subject: Re: POST example for webrick? GOTOU Yuuzou wrote: > `Martin Pirker ' wrote: >> Is there somewhere some example code for handling a file upload via >> webrick, meaning a simple form with a (local) file selector, then doing >> a POST(?) operation and webrick receives and dumps the file somewhere. > > How about the attached sample? That's an informative sample - thanks! I almost guessed it could be done with such small code, only one has to know how... I made a printout of all the webrick code and hopefully find more about how this thing ticks inside :-) >> As a must requirement, there must be a way to restrict upload size >> (e.g. 100kb) to stop malicious users. > > Request body is not read from socket when servlets are > started. If the value of content-length is too large, we can > pass the process of servlets by raising an exception. But > HTTPServer is going to read the body before sending response;-) > > Is it better that there is a way to shutdown the socket > without reading request? It would be good to stop reading unwanted data, otherwise one with a fast connection can almost denial of service other slow (modem) users. Ok, the really evil attacker who fakes the Content-Length header maybe cannot be stopped, but the "wrong file" uploader shouldn't affect the server performance so much. Martin