title: Is it advisable to (further) limit the size of forms when using golang?
body: <p>I searched around and as far as I can tell, POST form requests are already limited to 10MB (<a href="http://golang.org/src/net/http/request.go#L721" rel="noreferrer">http://golang.org/src/net/http/request.go#L721</a>). </p>
  
  <p>If I were to go about reducing this in my <code>ServeHTTP</code> method, I'm not sure how to properly do it. I would try something like this:</p>
  
  <pre><code>r.Body = http.MaxBytesReader(w, r.Body, MaxFileSize) 
  err := r.ParseForm()
  if err != nil {
       //redirect to some error page
       return
  }
  </code></pre>
  
  <p>But would returning upon error close the connection as well? How would I prevent having to read everything? I found this: <a href="https://stackoverflow.com/a/26393261/2202497">https://stackoverflow.com/a/26393261/2202497</a>, but what if content length is not set and in the middle of reading I realize that the file is too big.</p>
  
  <p>I'm using this as a security measure to prevent someone from hogging my server's resources.</p>