Class: HttpKit::RackHandler

Inherits:
RingHandler
  • Object
show all
Defined in:
lib/http_kit/rack_handler.rb

Instance Method Summary collapse

Instance Method Details

#client_close(channel, status) ⇒ Object

java_signature %Q{ @override public void clientClose(AsyncChannel channel, int status) }



128
129
130
# File 'lib/http_kit/rack_handler.rb', line 128

def client_close(channel, status)

end

#closeObject

java_signature %Q{ @override void close() }



134
135
136
# File 'lib/http_kit/rack_handler.rb', line 134

def close

end

#handle(*args) ⇒ Object



104
105
106
107
108
109
110
# File 'lib/http_kit/rack_handler.rb', line 104

def handle(*args)
  if args[0].is_a?(HttpRequest) && args[1].is_a?(RespCallback)
    handle_http(args[0], args[1])
  else
    handle_async(args[0], args[1])
  end
end

#handle_async(channel, frame) ⇒ Object

void handle(AsyncChannel channel, Frame frame)



123
124
125
# File 'lib/http_kit/rack_handler.rb', line 123

def handle_async(channel, frame)

end

#handle_http(request, callback) ⇒ Object

void handle(HttpRequest request, RespCallback callback)



113
114
115
116
117
118
119
120
# File 'lib/http_kit/rack_handler.rb', line 113

def handle_http(request, callback)
  begin
    execs.submit( HttpKit::HttpHandler.new(request, callback, handler) )
  rescue java.util.concurrent.RejectedExecutionException => e
    HttpUtils.printError("increase :queue-size if this happens often", e);
    callback.run(HttpUtils.HttpEncode(503, HeaderMap.new(), "Server is overloaded, please try later"));
  end
end