Revision: 10067
          http://sourceforge.net/p/languagetool/code/10067
Author:   dnaber
Date:     2013-05-11 14:22:05 +0000 (Sat, 11 May 2013)
Log Message:
-----------
consume the request before checking for limits - not doing so seems to cause 
hangs when the request limit becomes active several times

Modified Paths:
--------------
    
trunk/languagetool/languagetool-server/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java

Modified: 
trunk/languagetool/languagetool-server/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java
===================================================================
--- 
trunk/languagetool/languagetool-server/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java
   2013-05-10 21:20:10 UTC (rev 10066)
+++ 
trunk/languagetool/languagetool-server/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java
   2013-05-11 14:22:05 UTC (rev 10067)
@@ -91,6 +91,10 @@
     try {
       final URI requestedUri = httpExchange.getRequestURI();
       final String remoteAddress = 
httpExchange.getRemoteAddress().getAddress().getHostAddress();
+      // According to the Javadoc, "Closing an exchange without consuming all 
of the request body is
+      // not an error but may make the underlying TCP connection unusable for 
following exchanges.",
+      // so we consume the request now, even before checking for request 
limits:
+      final Map<String, String> parameters = getRequestQuery(httpExchange, 
requestedUri);
       if (requestLimiter != null && 
!requestLimiter.isAccessOkay(remoteAddress)) {
         final String errorMessage = "Error: Access from " + 
StringTools.escapeXML(remoteAddress) +
                 " denied - too many requests. Allowed maximum requests: " + 
requestLimiter.getRequestLimit() +
@@ -99,7 +103,6 @@
         print(errorMessage);
         return;
       }
-      final Map<String, String> parameters = getRequestQuery(httpExchange, 
requestedUri);
       if (allowedIps == null || allowedIps.contains(remoteAddress)) {
         if (requestedUri.getRawPath().endsWith("/Languages")) {
           // request type: list known languages

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits

Reply via email to