[Groonga-commit] groonga/fluent-plugin-groonga at 06e9d76 [master] input http: support "Host" rewriting

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Jun 5 11:09:56 JST 2016


Kouhei Sutou	2016-06-05 11:09:56 +0900 (Sun, 05 Jun 2016)

  New Revision: 06e9d76569a172326a8258cd85bab45aa4c14ac5
  https://github.com/groonga/fluent-plugin-groonga/commit/06e9d76569a172326a8258cd85bab45aa4c14ac5

  Message:
    input http: support "Host" rewriting
    
    groonga-httpd (nginx) doesn't accept request that its "Host" value isn't
    matched.
    
    [groonga-dev,04037]
    
    Reported by Hiroaki TACHIKAWA. Thanks!!!

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

  Modified: lib/fluent/plugin/in_groonga.rb (+25 -2)
===================================================================
--- lib/fluent/plugin/in_groonga.rb    2016-05-27 17:04:00 +0900 (e8dd723)
+++ lib/fluent/plugin/in_groonga.rb    2016-06-05 11:09:56 +0900 (e383ef3)
@@ -196,8 +196,15 @@ module Fluent
         end
 
         def on_read(data)
-          @parser << data
-          @repeater.write(data)
+          begin
+            @parser << data
+          rescue HTTP::Parser::Error
+            $log.error("[input][groonga][error] " +
+                       "failed to parse HTTP request:",
+                       :error => $!.to_s)
+            $log.error_backtrace
+            close
+          end
         end
 
         def on_message_begin
@@ -205,10 +212,26 @@ module Fluent
         end
 
         def on_headers_complete(headers)
+          method =****@parse*****_method
+          url =****@parse*****_url
+          http_version =****@parse*****_version.join(".")
+          @repeater.write("#{method} #{url} HTTP/#{http_version}\r\n")
+          headers.each do |name, value|
+            case name
+            when /\AHost\z/i
+              real_host =****@input*****_host
+              real_port =****@input*****_port
+              @repeater.write("#{name}: #{real_host}:#{real_port}\r\n")
+            else
+              @repeater.write("#{name}: #{value}\r\n")
+            end
+          end
+          @repeater.write("\r\n")
         end
 
         def on_body(chunk)
           @body << chunk
+          @repeater.write(chunk)
         end
 
         def on_message_complete
-------------- next part --------------
HTML����������������������������...
Download 



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