title: How to close TCP connection when invalid user trying to POST large file?
body: <p>I wrote a simple HTTP responding C++ program using <a href="http://www.fastcgi.com" rel="nofollow">http://www.fastcgi.com</a> library + nginx web-server. It works almost great. But I noticed that fcgi's function</p>
  
  <pre><code>int FCGX_Accept_r(FCGX_Request *request);
  </code></pre>
  
  <p>doesnt return before all the request transmitted to the server. The problem: i am unable to analyze parameters from URI before file transmission is finished: i want to analyze "?sid=" argument to reject transmission from invalid user. It would be a waste of bandwidth to allow anyone send 1GB files to a server.</p>
  
  <p>As i know, web-server always send FCGI_BEGIN_REQUEST via FastCGI connection when new request started, then FCGI_PARAMS etc. So it would be good to react to content of some parameters before user transmitted all the (possibly unneeded and too large) data.</p>
  
  <p>Also i will read more nginx documentation about its FastCGI abilities.</p>
  
  <p><b>update:</b>
  Trying to send 2 GB file to nginx via HTML-form + sniffing the exchange between nginx and fastcgi: nginx doesn't even try to send a byte to FastCGI application before all the 2GB has come. So, this behavior is kinda normal. And if you want the functionality i am asking for, it turns out that you should develop your own nginx's module or simple web-server. Hm...</p>