Class: ASIR::Transport::HTTP
- Inherits:
-
ASIR::Transport
- Object
- ASIR::Transport
- ASIR::Transport::HTTP
- Defined in:
- lib/asir/transport/http.rb
Overview
!SLIDE HTTP Transport
Using HTTPClient.
Constant Summary collapse
- CONTENT_TYPE =
'Content-Type'.freeze
- APPLICATION_BINARY =
'application/binary'.freeze
Constants included from ASIR::ThreadVariable
ASIR::ThreadVariable::DEBUG, ASIR::ThreadVariable::EMPTY_HASH, ASIR::ThreadVariable::SETTER
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#server ⇒ Object
Returns the value of attribute server.
-
#uri ⇒ Object
Returns the value of attribute uri.
Attributes inherited from ASIR::Transport
#after_invoke_message, #after_receive_message, #before_send_message, #coder_needs_result_message, #decoder, #encoder, #invoker, #message_count, #needs_message_identifier, #needs_message_timestamp, #on_exception, #on_result_exception, #one_way, #running, #verbose
Attributes included from Log
Instance Method Summary collapse
-
#_receive_result(state) ⇒ Object
Recieve the Result payload String from the opaque HTTPClient::Request response object returned from #_send_message.
-
#_send_message(state) ⇒ Object
Send the Message payload String using HTTP POST.
-
#client ⇒ Object
Client-side: HTTPClient.
- #close ⇒ Object
-
#message_uri(state) ⇒ Object
Subclasses can override.
Methods inherited from ASIR::Transport
#_after_invoke_message, #_subclass_responsibility, #initialize, #invoke_message!, #needs_message_identifier?, #needs_message_timestamp?, #receive_message, #receive_result, #send_message, #send_result, #serve_message!, #stop!, #with_force_stop!, #with_server_signals!
Methods included from Log
#_log, #_log_enabled=, #_log_enabled?, #_log_format, #_log_result, enabled, enabled=, included
Methods included from Initialization
Methods included from AdditionalData
#[], #[]=, #_additional_data, #additional_data, #additional_data!, #additional_data=, included
Methods included from Message::Delay
#relative_message_delay!, #wait_for_delay!
Methods included from ASIR::ThreadVariable
Constructor Details
This class inherits a constructor from ASIR::Transport
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
15 16 17 |
# File 'lib/asir/transport/http.rb', line 15 def debug @debug end |
#server ⇒ Object
Returns the value of attribute server.
15 16 17 |
# File 'lib/asir/transport/http.rb', line 15 def server @server end |
#uri ⇒ Object
Returns the value of attribute uri.
15 16 17 |
# File 'lib/asir/transport/http.rb', line 15 def uri @uri end |
Instance Method Details
#_receive_result(state) ⇒ Object
Recieve the Result payload String from the opaque HTTPClient::Request response object returned from #_send_message.
47 48 49 50 |
# File 'lib/asir/transport/http.rb', line 47 def _receive_result state state.result_payload = state.in_stream.content.to_s end |
#_send_message(state) ⇒ Object
Send the Message payload String using HTTP POST. Returns the HTTPClient::Request response object.
33 34 35 36 37 38 |
# File 'lib/asir/transport/http.rb', line 33 def state client.with_stream! do | client | state.in_stream = client.post((state), state.) end end |
#client ⇒ Object
Client-side: HTTPClient
19 20 21 22 23 |
# File 'lib/asir/transport/http.rb', line 19 def client @client ||= Channel.new(:on_connect => lambda { | channel | ::HTTPClient.new }) end |
#close ⇒ Object
25 26 27 28 29 |
# File 'lib/asir/transport/http.rb', line 25 def close @client.close if @client ensure @client = nil unless Channel === @client end |
#message_uri(state) ⇒ Object
Subclasses can override.
41 42 43 |
# File 'lib/asir/transport/http.rb', line 41 def state state.[:uri] || uri end |