[Groonga-commit] groonga/fluent-plugin-groonga at 48d05f4 [master] Ensure sending response on unknown error

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Sep 27 19:22:13 JST 2016


Kouhei Sutou	2016-09-27 19:22:13 +0900 (Tue, 27 Sep 2016)

  New Revision: 48d05f484beacadf389939d5efa0ede0d831cd99
  https://github.com/groonga/fluent-plugin-groonga/commit/48d05f484beacadf389939d5efa0ede0d831cd99

  Message:
    Ensure sending response on unknown error

  Modified files:
    lib/fluent/plugin/in_groonga.rb

  Modified: lib/fluent/plugin/in_groonga.rb (+19 -9)
===================================================================
--- lib/fluent/plugin/in_groonga.rb    2016-09-27 19:19:47 +0900 (8dc8429)
+++ lib/fluent/plugin/in_groonga.rb    2016-09-27 19:22:13 +0900 (301882c)
@@ -227,15 +227,13 @@ module Fluent
                        "failed to parse HTTP request:",
                        :error => "#{$!.class}: #{$!}")
             $log.error_backtrace
-            write("HTTP1.1 400 Bad Request\r\n")
-            write("Server: fluent-plugin-groonga\r\n")
-            write("Connection: close\r\n")
-            write("Content-Length: 0\r\n")
-            write("\r\n")
-            disable
-            on_write_complete do
-              close
-            end
+            write_error_response("400 Bad Request")
+          rescue
+            $log.error("[input][groonga][error] " +
+                       "failed to handle HTTP request:",
+                       :error => "#{$!.class}: #{$!}")
+            $log.error_backtrace
+            write_error_response("500 Internal Server Error")
           end
         end
 
@@ -269,6 +267,18 @@ module Fluent
             false
           end
         end
+
+        def write_error_response(status)
+          write("HTTP1.1 #{status}\r\n")
+          write("Server: fluent-plugin-groonga\r\n")
+          write("Connection: close\r\n")
+          write("Content-Length: 0\r\n")
+          write("\r\n")
+          disable
+          on_write_complete do
+            close
+          end
+        end
       end
 
       class RequestHandler
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index