m2r 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +64 -1
- data/example/config.sqlite +0 -0
- data/example/http_0mq.rb +10 -3
- data/example/tmp/access.log +215 -0
- data/lib/m2r.rb +1 -0
- data/lib/m2r/connection.rb +21 -10
- data/lib/m2r/connection_factory.rb +20 -17
- data/lib/m2r/handler.rb +40 -3
- data/lib/m2r/headers.rb +9 -1
- data/lib/m2r/http/close.rb +30 -0
- data/lib/m2r/rack_handler.rb +3 -3
- data/lib/m2r/reply.rb +15 -0
- data/lib/m2r/request.rb +38 -31
- data/lib/m2r/request/base.rb +0 -8
- data/lib/m2r/request/upload.rb +0 -10
- data/lib/m2r/response.rb +64 -18
- data/lib/m2r/response/always_close.rb +26 -0
- data/lib/m2r/response/content_length.rb +8 -2
- data/lib/m2r/response/to_request.rb +26 -0
- data/lib/m2r/version.rb +1 -1
- data/lib/rack/handler/mongrel2.rb +17 -3
- data/test/support/test_handler.rb +5 -1
- data/test/unit/connection_factory_test.rb +3 -3
- data/test/unit/connection_test.rb +60 -9
- data/test/unit/handler_test.rb +46 -9
- data/test/unit/headers_test.rb +13 -0
- data/test/unit/rack_handler_test.rb +26 -2
- data/test/unit/request_test.rb +1 -0
- data/test/unit/response_test.rb +76 -5
- metadata +7 -3
data/README.md
CHANGED
@@ -5,6 +5,12 @@ A [Mongrel2](http://mongrel2.org/) [™](#legal) backend handler written in Ruby
|
|
5
5
|
|
6
6
|
[](http://travis-ci.org/perplexes/m2r) [](https://gemnasium.com/perplexes/m2r)
|
7
7
|
|
8
|
+
Documentation
|
9
|
+
-------------
|
10
|
+
|
11
|
+
* [Tutorial](http://documentup.com/perplexes/m2r/recompile)
|
12
|
+
* [API](http://www.rubydoc.info/gems/m2r/frames)
|
13
|
+
|
8
14
|
Installation
|
9
15
|
------------
|
10
16
|
|
@@ -55,7 +61,7 @@ rack_example = Handler(
|
|
55
61
|
|
56
62
|
Add `-O option_name` to provide options for m2r handler:
|
57
63
|
|
58
|
-
```
|
64
|
+
```bash
|
59
65
|
[bundle exec] rackup -s mongrel2 another.ru -O recv_addr=tcp://127.0.0.1:9995 -O send_addr=tcp://127.0.0.1:9994
|
60
66
|
```
|
61
67
|
|
@@ -63,6 +69,63 @@ Add `-O option_name` to provide options for m2r handler:
|
|
63
69
|
|
64
70
|
* `recv_addr` - This is the `send_spec` option from `Handler` configuration in `mongrel2.conf`. Default: `tcp://127.0.0.1:9997`
|
65
71
|
* `send_addr` - This is the `recv_spec` option from `Handler` configuration in your `mongrel2.conf`. Default: `tcp://127.0.0.1:9996`
|
72
|
+
* `factory` - Use it to load custom `ConnectionFactory` that implements rules for ZMQ connections to Mongrel 2.
|
73
|
+
|
74
|
+
#### Custom Connection Factory
|
75
|
+
|
76
|
+
ZMQ allows to set multiple options and connect to large number of endpoints. Providing every ZMQ option for handler connections
|
77
|
+
would be troublesome. Instead you can use your custom implementation that deals only with that fact.
|
78
|
+
|
79
|
+
##### Automatic require of custom connection factory
|
80
|
+
|
81
|
+
The first way to do it is to implement custom class in a file that can be required with `m2r/connection_factory/custom_name`.
|
82
|
+
The location of such file might depends on how `$LOAD_PATH` is configured but for standard Rails application or gem that
|
83
|
+
would like to depend on `m2r` it would be: `lib/m2r/connection_factory/custom_name`.
|
84
|
+
|
85
|
+
Implement the Factory in the file:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
module M2R
|
89
|
+
class ConnectionFactory
|
90
|
+
# Just exemplary implementation ...
|
91
|
+
class CustomName < ConnectionFactory
|
92
|
+
def initialize(options)
|
93
|
+
# OpenStruct with rackup options for the handler (added with -O)
|
94
|
+
@options = options
|
95
|
+
end
|
96
|
+
|
97
|
+
def connection
|
98
|
+
request_socket = @context.socket(ZMQ::PULL)
|
99
|
+
request_socket.connect("tcp://127.0.0.1:2222")
|
100
|
+
request_socket.setsockopt(ZMQ::RECONNECT_IVL, 5)
|
101
|
+
|
102
|
+
response_socket = @context.socket(ZMQ::PUB)
|
103
|
+
response_socket.connect("tcp://127.0.0.1:3333")
|
104
|
+
response_socket.setsockopt(ZMQ::HWM, 100)
|
105
|
+
response_socket.setsockopt(ZMQ::RECONNECT_IVL, 5)
|
106
|
+
|
107
|
+
Connection.new(request_socket, response_socket)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
```
|
113
|
+
|
114
|
+
Use `connection_factory` option to select it.
|
115
|
+
|
116
|
+
```bash
|
117
|
+
[bundle exec] rackup -s mongrel2 another.ru -O connection_factory=custom_name
|
118
|
+
```
|
119
|
+
|
120
|
+
##### Manual require of factory
|
121
|
+
|
122
|
+
Implement custom factory in a file like in a previous paragraph.
|
123
|
+
|
124
|
+
Load the file using `-r` option for `rackup` and use `connection_factory` option.
|
125
|
+
|
126
|
+
```bash
|
127
|
+
[bundle exec] rackup -r custom_name.rb -s mongrel2 another.ru -O connection_factory=custom_name
|
128
|
+
```
|
66
129
|
|
67
130
|
#### Processing HTTPS requests from Mongrel2 1.7
|
68
131
|
|
data/example/config.sqlite
CHANGED
Binary file
|
data/example/http_0mq.rb
CHANGED
@@ -22,6 +22,12 @@ class Http0MQHandler < M2R::Handler
|
|
22
22
|
puts "DISCONNECT"
|
23
23
|
end
|
24
24
|
|
25
|
+
def on_error(request, response, error)
|
26
|
+
puts "ERROR:"
|
27
|
+
puts error.message
|
28
|
+
puts *error.backtrace
|
29
|
+
end
|
30
|
+
|
25
31
|
def process(request)
|
26
32
|
body = <<EOF
|
27
33
|
<pre>
|
@@ -30,14 +36,14 @@ IDENT: #{request.conn_id}
|
|
30
36
|
PATH: #{request.path}
|
31
37
|
HEADERS: #{MultiJson.dump(request.headers.inject({}) {|hash,(h,v)| hash[h]=v; hash }, :pretty => true)}
|
32
38
|
PATTERN: #{request.pattern}
|
39
|
+
VERSION: #{request.http_version}
|
33
40
|
METHOD: #{request.method}
|
34
41
|
QUERY: #{request.query}
|
35
42
|
SCHEME: #{request.scheme}
|
36
43
|
BODY: #{request.body.inspect}
|
37
44
|
</pre>
|
38
45
|
EOF
|
39
|
-
response = M2R::
|
40
|
-
response.extend(M2R::Response::ContentLength)
|
46
|
+
response = M2R::Reply.new.to(request).body(body)
|
41
47
|
return response
|
42
48
|
end
|
43
49
|
end
|
@@ -46,6 +52,7 @@ sender_id = "34f9ceee-cd52-4b7f-b197-88bf2f0ec378"
|
|
46
52
|
pull_port = "tcp://127.0.0.1:9999"
|
47
53
|
pub_port = "tcp://127.0.0.1:9998"
|
48
54
|
|
49
|
-
|
55
|
+
factory = M2R::ConnectionFactory.new M2R::ConnectionFactory::Options.new(sender_id, pull_port, pub_port)
|
56
|
+
handler = Http0MQHandler.new(factory, M2R::Request)
|
50
57
|
handler.listen
|
51
58
|
|
data/example/tmp/access.log
CHANGED
@@ -503,3 +503,218 @@
|
|
503
503
|
84:9:127.0.0.1,9:127.0.0.1,5:57884#10:1351546622#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
504
504
|
81:9:127.0.0.1,9:127.0.0.1,5:57889#10:1351546625#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
505
505
|
81:9:127.0.0.1,9:127.0.0.1,5:57889#10:1351546625#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
506
|
+
87:9:127.0.0.1,9:127.0.0.1,5:44683#10:1351766783#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
507
|
+
92:9:127.0.0.1,9:127.0.0.1,5:44683#10:1351766783#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
508
|
+
81:9:127.0.0.1,9:127.0.0.1,5:44929#10:1351767448#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
509
|
+
81:9:127.0.0.1,9:127.0.0.1,5:44930#10:1351767452#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
510
|
+
81:9:127.0.0.1,9:127.0.0.1,5:44931#10:1351767453#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
511
|
+
87:9:127.0.0.1,9:127.0.0.1,5:44932#10:1351767457#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
512
|
+
77:9:127.0.0.1,9:127.0.0.1,5:44933#10:1351767461#3:GET,1:/,8:HTTP/1.1,3:200#1:0#]
|
513
|
+
87:9:127.0.0.1,9:127.0.0.1,5:45181#10:1351767507#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
514
|
+
92:9:127.0.0.1,9:127.0.0.1,5:45181#10:1351767507#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
515
|
+
87:9:127.0.0.1,9:127.0.0.1,5:45181#10:1351767507#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
516
|
+
84:9:127.0.0.1,9:127.0.0.1,5:45186#10:1351767511#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
517
|
+
81:9:127.0.0.1,9:127.0.0.1,5:45190#10:1351767515#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
518
|
+
81:9:127.0.0.1,9:127.0.0.1,5:45190#10:1351767515#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
519
|
+
81:9:127.0.0.1,9:127.0.0.1,5:45197#10:1351767546#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
520
|
+
81:9:127.0.0.1,9:127.0.0.1,5:45197#10:1351767546#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
521
|
+
87:9:127.0.0.1,9:127.0.0.1,5:45204#10:1351767550#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
522
|
+
92:9:127.0.0.1,9:127.0.0.1,5:45204#10:1351767550#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
523
|
+
87:9:127.0.0.1,9:127.0.0.1,5:45204#10:1351767550#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
524
|
+
84:9:127.0.0.1,9:127.0.0.1,5:45207#10:1351767554#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
525
|
+
81:9:127.0.0.1,9:127.0.0.1,5:45899#10:1351773762#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
526
|
+
81:9:127.0.0.1,9:127.0.0.1,5:45899#10:1351773762#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
527
|
+
87:9:127.0.0.1,9:127.0.0.1,5:45907#10:1351773766#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
528
|
+
92:9:127.0.0.1,9:127.0.0.1,5:45907#10:1351773766#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
529
|
+
87:9:127.0.0.1,9:127.0.0.1,5:45907#10:1351773766#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
530
|
+
84:9:127.0.0.1,9:127.0.0.1,5:45914#10:1351773770#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
531
|
+
84:9:127.0.0.1,9:127.0.0.1,5:46036#10:1351775563#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
532
|
+
81:9:127.0.0.1,9:127.0.0.1,5:46979#10:1351777458#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
533
|
+
81:9:127.0.0.1,9:127.0.0.1,5:46979#10:1351777458#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
534
|
+
87:9:127.0.0.1,9:127.0.0.1,5:46982#10:1351777462#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
535
|
+
92:9:127.0.0.1,9:127.0.0.1,5:46982#10:1351777462#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
536
|
+
87:9:127.0.0.1,9:127.0.0.1,5:46982#10:1351777462#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
537
|
+
84:9:127.0.0.1,9:127.0.0.1,5:46990#10:1351777465#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
538
|
+
84:9:127.0.0.1,9:127.0.0.1,5:47031#10:1351795950#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
539
|
+
81:9:127.0.0.1,9:127.0.0.1,5:47038#10:1351795954#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
540
|
+
81:9:127.0.0.1,9:127.0.0.1,5:47038#10:1351795954#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
541
|
+
87:9:127.0.0.1,9:127.0.0.1,5:47045#10:1351795958#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
542
|
+
92:9:127.0.0.1,9:127.0.0.1,5:47045#10:1351795958#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
543
|
+
87:9:127.0.0.1,9:127.0.0.1,5:47045#10:1351795958#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
544
|
+
84:9:127.0.0.1,9:127.0.0.1,5:49179#10:1351865789#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
545
|
+
81:9:127.0.0.1,9:127.0.0.1,5:49187#10:1351865793#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
546
|
+
81:9:127.0.0.1,9:127.0.0.1,5:49187#10:1351865793#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
547
|
+
87:9:127.0.0.1,9:127.0.0.1,5:49194#10:1351865797#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
548
|
+
92:9:127.0.0.1,9:127.0.0.1,5:49194#10:1351865797#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
549
|
+
87:9:127.0.0.1,9:127.0.0.1,5:49194#10:1351865797#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
550
|
+
84:9:127.0.0.1,9:127.0.0.1,5:53392#10:1351943699#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
551
|
+
84:9:127.0.0.1,9:127.0.0.1,5:53395#10:1351943723#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
552
|
+
84:9:127.0.0.1,9:127.0.0.1,5:53443#10:1351943851#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
553
|
+
84:9:127.0.0.1,9:127.0.0.1,5:53511#10:1351945404#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
554
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54060#10:1351948242#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
555
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54061#10:1351948242#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
556
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54062#10:1351948243#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
557
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54063#10:1351948243#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
558
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54064#10:1351948259#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
559
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54065#10:1351948261#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
560
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54066#10:1351948261#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
561
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54067#10:1351948262#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
562
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54068#10:1351948262#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
563
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54069#10:1351948263#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
564
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54192#10:1351948309#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
565
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54192#10:1351948309#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
566
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54192#10:1351948309#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
567
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54199#10:1351948316#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
568
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54217#10:1351948611#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
569
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54222#10:1351948615#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
570
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54222#10:1351948615#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
571
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54228#10:1351948619#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
572
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54228#10:1351948619#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
573
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54228#10:1351948619#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
574
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54257#10:1351949253#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
575
|
+
90:9:127.0.0.1,9:127.0.0.1,5:54258#10:1351949260#4:POST,10:/uploading,8:HTTP/1.1,3:200#3:464#]
|
576
|
+
90:9:127.0.0.1,9:127.0.0.1,5:54259#10:1351949268#4:POST,10:/uploading,8:HTTP/1.1,3:200#3:464#]
|
577
|
+
91:9:127.0.0.1,9:127.0.0.1,5:54260#10:1351949275#4:POST,10:/uploading,8:HTTP/1.1,3:200#4:1799#]
|
578
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54369#10:1351949362#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
579
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54374#10:1351949366#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
580
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54374#10:1351949366#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
581
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54380#10:1351949370#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
582
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54380#10:1351949370#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
583
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54380#10:1351949370#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
584
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54383#10:1351949422#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
585
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54383#10:1351949422#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
586
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54383#10:1351949422#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
587
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54386#10:1351949429#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
588
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54393#10:1351949445#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
589
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54393#10:1351949445#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
590
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54393#10:1351949445#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
591
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54396#10:1351949452#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
592
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54399#10:1351949487#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
593
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54404#10:1351949491#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
594
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54404#10:1351949491#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
595
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54411#10:1351949496#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
596
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54411#10:1351949496#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
597
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54411#10:1351949496#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
598
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54740#10:1351962447#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
599
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54740#10:1351962447#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
600
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54745#10:1351962451#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
601
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54748#10:1351962454#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
602
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54748#10:1351962454#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
603
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54748#10:1351962454#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
604
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54764#10:1351962848#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
605
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54764#10:1351962848#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
606
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54764#10:1351962848#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
607
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54773#10:1351962867#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
608
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54773#10:1351962867#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
609
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54773#10:1351962867#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
610
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54778#10:1351962957#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
611
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54778#10:1351962957#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
612
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54778#10:1351962960#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
613
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54786#10:1351963028#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
614
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54786#10:1351963028#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
615
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54786#10:1351963031#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
616
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54797#10:1351963120#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
617
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54797#10:1351963120#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
618
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54797#10:1351963123#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
619
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54810#10:1351963242#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
620
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54810#10:1351963242#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
621
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54810#10:1351963245#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
622
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54820#10:1351963392#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
623
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54820#10:1351963392#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
624
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54820#10:1351963395#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
625
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54869#10:1351963895#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
626
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54879#10:1351964023#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
627
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54886#10:1351964062#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
628
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54886#10:1351964062#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
629
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54893#10:1351964197#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
630
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54896#10:1351964249#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
631
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54896#10:1351964249#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
632
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54896#10:1351964252#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
633
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54909#10:1351964346#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
634
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54909#10:1351964346#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
635
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54909#10:1351964346#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
636
|
+
84:9:127.0.0.1,9:127.0.0.1,5:54917#10:1351964378#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
637
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54923#10:1351964382#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
638
|
+
81:9:127.0.0.1,9:127.0.0.1,5:54923#10:1351964382#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
639
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54930#10:1351964385#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
640
|
+
92:9:127.0.0.1,9:127.0.0.1,5:54930#10:1351964385#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
641
|
+
87:9:127.0.0.1,9:127.0.0.1,5:54930#10:1351964385#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
642
|
+
87:9:127.0.0.1,9:127.0.0.1,5:55098#10:1351964801#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
643
|
+
92:9:127.0.0.1,9:127.0.0.1,5:55098#10:1351964801#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
644
|
+
87:9:127.0.0.1,9:127.0.0.1,5:55098#10:1351964801#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
645
|
+
81:9:127.0.0.1,9:127.0.0.1,5:55103#10:1351964805#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
646
|
+
81:9:127.0.0.1,9:127.0.0.1,5:55103#10:1351964805#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
647
|
+
84:9:127.0.0.1,9:127.0.0.1,5:55108#10:1351964808#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
648
|
+
87:9:127.0.0.1,9:127.0.0.1,5:55114#10:1351964846#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
649
|
+
92:9:127.0.0.1,9:127.0.0.1,5:55114#10:1351964846#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
650
|
+
87:9:127.0.0.1,9:127.0.0.1,5:55114#10:1351964846#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
651
|
+
81:9:127.0.0.1,9:127.0.0.1,5:55121#10:1351964850#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
652
|
+
81:9:127.0.0.1,9:127.0.0.1,5:55121#10:1351964850#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
653
|
+
84:9:127.0.0.1,9:127.0.0.1,5:55126#10:1351964853#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
654
|
+
87:9:127.0.0.1,9:127.0.0.1,5:55135#10:1351964952#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
655
|
+
92:9:127.0.0.1,9:127.0.0.1,5:55135#10:1351964952#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
656
|
+
87:9:127.0.0.1,9:127.0.0.1,5:55135#10:1351964952#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
657
|
+
81:9:127.0.0.1,9:127.0.0.1,5:55142#10:1351964956#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
658
|
+
81:9:127.0.0.1,9:127.0.0.1,5:55142#10:1351964956#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
659
|
+
84:9:127.0.0.1,9:127.0.0.1,5:55149#10:1351964960#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
660
|
+
87:9:127.0.0.1,9:127.0.0.1,5:56265#10:1351969992#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
661
|
+
92:9:127.0.0.1,9:127.0.0.1,5:56265#10:1351969992#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
662
|
+
87:9:127.0.0.1,9:127.0.0.1,5:56265#10:1351969992#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
663
|
+
81:9:127.0.0.1,9:127.0.0.1,5:56270#10:1351969996#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
664
|
+
81:9:127.0.0.1,9:127.0.0.1,5:56270#10:1351969996#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
665
|
+
84:9:127.0.0.1,9:127.0.0.1,5:56277#10:1351970000#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
666
|
+
87:9:127.0.0.1,9:127.0.0.1,5:56497#10:1351973239#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
667
|
+
92:9:127.0.0.1,9:127.0.0.1,5:56497#10:1351973239#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
668
|
+
87:9:127.0.0.1,9:127.0.0.1,5:56497#10:1351973239#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
669
|
+
84:9:127.0.0.1,9:127.0.0.1,5:56502#10:1351973243#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
670
|
+
81:9:127.0.0.1,9:127.0.0.1,5:56505#10:1351973247#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
671
|
+
81:9:127.0.0.1,9:127.0.0.1,5:56505#10:1351973247#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
672
|
+
81:9:127.0.0.1,9:127.0.0.1,5:56609#10:1351986746#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
673
|
+
81:9:127.0.0.1,9:127.0.0.1,5:56612#10:1351986756#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
674
|
+
81:9:127.0.0.1,9:127.0.0.1,5:56614#10:1351986829#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
675
|
+
81:9:127.0.0.1,9:127.0.0.1,5:56619#10:1351986875#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
676
|
+
87:9:127.0.0.1,9:127.0.0.1,5:56899#10:1351990066#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
677
|
+
92:9:127.0.0.1,9:127.0.0.1,5:56899#10:1351990066#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
678
|
+
87:9:127.0.0.1,9:127.0.0.1,5:56899#10:1351990066#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
679
|
+
81:9:127.0.0.1,9:127.0.0.1,5:56906#10:1351990070#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
680
|
+
81:9:127.0.0.1,9:127.0.0.1,5:56906#10:1351990070#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
681
|
+
84:9:127.0.0.1,9:127.0.0.1,5:56909#10:1351990074#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
682
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57115#10:1351990309#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
683
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57124#10:1351990370#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
684
|
+
81:9:127.0.0.1,9:127.0.0.1,5:57139#10:1351990418#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
685
|
+
81:9:127.0.0.1,9:127.0.0.1,5:57140#10:1351990422#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
686
|
+
81:9:127.0.0.1,9:127.0.0.1,5:57141#10:1351990422#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
687
|
+
81:9:127.0.0.1,9:127.0.0.1,5:57142#10:1351990422#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
688
|
+
81:9:127.0.0.1,9:127.0.0.1,5:57143#10:1351990422#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
689
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57144#10:1351990431#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
690
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57346#10:1351990508#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
691
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57350#10:1351990539#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
692
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57412#10:1351990646#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
693
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57414#10:1351990658#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
694
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57415#10:1351990658#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
695
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57484#10:1351990706#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
696
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57532#10:1351990754#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
697
|
+
87:9:127.0.0.1,9:127.0.0.1,5:57590#10:1351991022#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
698
|
+
92:9:127.0.0.1,9:127.0.0.1,5:57590#10:1351991022#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
699
|
+
87:9:127.0.0.1,9:127.0.0.1,5:57590#10:1351991022#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
700
|
+
81:9:127.0.0.1,9:127.0.0.1,5:57593#10:1351991026#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
701
|
+
81:9:127.0.0.1,9:127.0.0.1,5:57593#10:1351991026#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
702
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57598#10:1351991030#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
703
|
+
84:9:127.0.0.1,9:127.0.0.1,5:57604#10:1351991063#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
704
|
+
81:9:127.0.0.1,9:127.0.0.1,5:57609#10:1351991067#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
705
|
+
81:9:127.0.0.1,9:127.0.0.1,5:57609#10:1351991067#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
706
|
+
87:9:127.0.0.1,9:127.0.0.1,5:57612#10:1351991071#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
707
|
+
92:9:127.0.0.1,9:127.0.0.1,5:57612#10:1351991071#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
708
|
+
87:9:127.0.0.1,9:127.0.0.1,5:57612#10:1351991071#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
709
|
+
87:9:127.0.0.1,9:127.0.0.1,5:58257#10:1351992771#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
710
|
+
92:9:127.0.0.1,9:127.0.0.1,5:58257#10:1351992771#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
711
|
+
87:9:127.0.0.1,9:127.0.0.1,5:58257#10:1351992771#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
712
|
+
81:9:127.0.0.1,9:127.0.0.1,5:58260#10:1351992775#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
713
|
+
81:9:127.0.0.1,9:127.0.0.1,5:58260#10:1351992775#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
714
|
+
84:9:127.0.0.1,9:127.0.0.1,5:58267#10:1351992779#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
715
|
+
87:9:127.0.0.1,9:127.0.0.1,5:58275#10:1351992979#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
716
|
+
92:9:127.0.0.1,9:127.0.0.1,5:58275#10:1351992979#4:POST,10:/uploading,8:HTTP/1.1,3:200#5:10437#]
|
717
|
+
87:9:127.0.0.1,9:127.0.0.1,5:58275#10:1351992979#3:GET,10:/uploading,8:HTTP/1.1,3:200#1:0#]
|
718
|
+
81:9:127.0.0.1,9:127.0.0.1,5:58280#10:1351992983#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
719
|
+
81:9:127.0.0.1,9:127.0.0.1,5:58280#10:1351992983#3:GET,5:/rack,8:HTTP/1.1,3:200#1:0#]
|
720
|
+
84:9:127.0.0.1,9:127.0.0.1,5:58285#10:1351992987#3:GET,8:/handler,8:HTTP/1.1,3:200#1:0#]
|
data/lib/m2r.rb
CHANGED
data/lib/m2r/connection.rb
CHANGED
@@ -3,18 +3,16 @@ require 'm2r'
|
|
3
3
|
module M2R
|
4
4
|
# Connection for exchanging data with mongrel2
|
5
5
|
class Connection
|
6
|
+
class Error < StandardError; end
|
6
7
|
|
7
8
|
# @param [ZMQ::Socket] request_socket socket for receiving requests
|
8
9
|
# from Mongrel2
|
9
10
|
# @param [ZMQ::Socket] response_socket socket for sending responses
|
10
11
|
# to Mongrel2
|
11
|
-
# @param [#parse] request_parser Object responsible for parsing Mongrel2
|
12
|
-
# requests
|
13
12
|
# @api public
|
14
|
-
def initialize(request_socket, response_socket
|
13
|
+
def initialize(request_socket, response_socket)
|
15
14
|
@request_socket = request_socket
|
16
15
|
@response_socket = response_socket
|
17
|
-
@request_parser = request_parser
|
18
16
|
end
|
19
17
|
|
20
18
|
# For compatibility with {M2R::ConnectionFactory}
|
@@ -25,23 +23,26 @@ module M2R
|
|
25
23
|
self
|
26
24
|
end
|
27
25
|
|
28
|
-
# Returns
|
26
|
+
# Returns Mongrel2 request
|
29
27
|
#
|
30
28
|
# @note This is blocking call
|
31
|
-
# @return [
|
29
|
+
# @return [String] M2 request message
|
32
30
|
# @api public
|
33
31
|
def receive
|
34
|
-
@request_socket.recv_string(msg = "")
|
35
|
-
|
32
|
+
ret = @request_socket.recv_string(msg = "")
|
33
|
+
raise Error, "Unable to receive message: #{ZMQ::Util.error_string}" if ret < 0
|
34
|
+
return msg
|
36
35
|
end
|
37
36
|
|
38
37
|
# Sends response to Mongrel2 for given request
|
39
38
|
#
|
40
39
|
# @param [Response, #to_s] response_or_string Response
|
41
40
|
# for the request. Anything convertable to [String]
|
41
|
+
# @return [String] M2 response message
|
42
42
|
# @api public
|
43
43
|
def reply(request, response_or_string)
|
44
44
|
deliver(request.sender, request.conn_id, response_or_string.to_s)
|
45
|
+
deliver(request.sender, request.conn_id, "") if close?(request, response_or_string)
|
45
46
|
end
|
46
47
|
|
47
48
|
# Delivers data to multiple mongrel2 connections.
|
@@ -50,17 +51,27 @@ module M2R
|
|
50
51
|
# @param [String] uuid Mongrel2 instance uuid
|
51
52
|
# @param [Array<String>, String] connection_ids Mongrel2 connections ids
|
52
53
|
# @param [String] data Data that should be delivered to the connections
|
54
|
+
# @return [String] M2 response message
|
53
55
|
#
|
54
56
|
# @api public
|
55
57
|
def deliver(uuid, connection_ids, data)
|
56
58
|
msg = "#{uuid} #{TNetstring.dump([*connection_ids].join(' '))} #{data}"
|
57
|
-
@response_socket.send_string(msg)
|
59
|
+
ret = @response_socket.send_string(msg, ZMQ::NOBLOCK)
|
60
|
+
raise Error, "Unable to deliver message: #{ZMQ::Util.error_string}" if ret < 0
|
61
|
+
return msg
|
58
62
|
end
|
59
63
|
|
60
64
|
private
|
61
65
|
|
66
|
+
def close?(request, response_or_string)
|
67
|
+
if response_or_string.respond_to?(:close?)
|
68
|
+
response_or_string.close?
|
69
|
+
else
|
70
|
+
request.close?
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
62
74
|
attr_reader :request_socket
|
63
75
|
attr_reader :response_socket
|
64
|
-
attr_reader :request_parser
|
65
76
|
end
|
66
77
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'm2r'
|
2
|
+
require 'ostruct'
|
2
3
|
|
3
4
|
module M2R
|
4
5
|
# {Connection} factory so that every thread can use it generate its own
|
@@ -6,35 +7,37 @@ module M2R
|
|
6
7
|
#
|
7
8
|
# @api public
|
8
9
|
class ConnectionFactory
|
10
|
+
class Options < Struct.new(:sender_id, :recv_addr, :send_addr)
|
11
|
+
# @param [String, nil] sender_id {ZMQ::IDENTITY} option for response socket
|
12
|
+
# @param [String] recv_addr ZMQ connection address. This is the
|
13
|
+
# send_spec option from Handler configuration in mongrel2.conf
|
14
|
+
# @param [String] send_addr ZMQ connection address. This is the
|
15
|
+
# recv_spec option from Handler configuration in mongrel2.conf
|
16
|
+
def initialize(sender_id, recv_addr, send_addr)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
9
20
|
|
10
|
-
# @param [
|
11
|
-
# @param [String] request_addr ZMQ connection address. This is the
|
12
|
-
# send_spec option from Handler configuration in mongrel2.conf
|
13
|
-
# @param [String] response_addr ZMQ connection address. This is the
|
14
|
-
# recv_spec option from Handler configuration in mongrel2.conf
|
15
|
-
# @param [#parse] request_parser Mongrel2 request parser
|
21
|
+
# @param [Options] options ZMQ connections options
|
16
22
|
# @param [ZMQ::Context] context Context for creating new ZMQ sockets
|
17
|
-
def initialize(
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@response_addr = response_addr.to_s
|
21
|
-
@request_parser = request_parser
|
22
|
-
@context = context
|
23
|
+
def initialize(options, context = M2R.zmq_context)
|
24
|
+
@options = options
|
25
|
+
@context = context
|
23
26
|
end
|
24
27
|
|
25
|
-
# Builds new Connection which can be used to receive
|
28
|
+
# Builds new Connection which can be used to receive
|
26
29
|
# Mongrel2 requests and send responses.
|
27
30
|
#
|
28
31
|
# @return [Connection]
|
29
32
|
def connection
|
30
33
|
request_socket = @context.socket(ZMQ::PULL)
|
31
|
-
request_socket.connect(@
|
34
|
+
request_socket.connect(@options.recv_addr)
|
32
35
|
|
33
36
|
response_socket = @context.socket(ZMQ::PUB)
|
34
|
-
response_socket.connect(@
|
35
|
-
response_socket.setsockopt(ZMQ::IDENTITY, @sender_id) if @sender_id
|
37
|
+
response_socket.connect(@options.send_addr)
|
38
|
+
response_socket.setsockopt(ZMQ::IDENTITY, @options.sender_id) if @options.sender_id
|
36
39
|
|
37
|
-
Connection.new(request_socket, response_socket
|
40
|
+
Connection.new(request_socket, response_socket)
|
38
41
|
end
|
39
42
|
|
40
43
|
end
|