@@ -364,6 +364,10 @@ def notfound_response
364364 string_response "Not found" , 404
365365 end
366366
367+ def no_content_response
368+ [ 204 , [ ] , [ ] ]
369+ end
370+
367371 def string_response string , status , content_type : nil
368372 string . force_encoding ::Encoding ::ASCII_8BIT unless string . valid_encoding?
369373 if string . encoding == ::Encoding ::ASCII_8BIT
@@ -403,7 +407,7 @@ def call env
403407 return notfound_response if excluded_path? env
404408 response =
405409 begin
406- logger = env [ "rack.logger" ] ||= @config . logger
410+ logger = env [ :: Rack :: RACK_LOGGER ] ||= @config . logger
407411 request = ::Rack ::Request . new env
408412 logger . info "FunctionsFramework: Handling HTTP #{ request . request_method } request"
409413 @function . call request , globals : @globals , logger : logger
@@ -426,7 +430,8 @@ def initialize function, globals, config
426430
427431 def call env
428432 return notfound_response if excluded_path? env
429- logger = env [ "rack.logger" ] ||= @config . logger
433+ return no_content_response if env [ ::Rack ::REQUEST_METHOD ] == "GET"
434+ logger = env [ ::Rack ::RACK_LOGGER ] ||= @config . logger
430435 event = decode_event env
431436 response =
432437 case event
@@ -448,9 +453,8 @@ def decode_event env
448453 begin
449454 @cloud_events . decode_event env
450455 rescue ::CloudEvents ::NotCloudEventError
451- env [ "rack.input" ] . rewind rescue nil
452- @legacy_events . decode_rack_env ( env ) ||
453- raise ( ::CloudEvents ::CloudEventsError , "Unrecognized event format" )
456+ env [ ::Rack ::RACK_INPUT ] . rewind rescue nil
457+ @legacy_events . decode_rack_env ( env ) || ::CloudEvents ::CloudEventsError . new ( "Unrecognized event format" )
454458 end
455459 rescue ::CloudEvents ::CloudEventsError => e
456460 e
0 commit comments