internethakai 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES
CHANGED
data/lib/internethakai/action.rb
CHANGED
@@ -161,7 +161,7 @@ module InternetHakai
|
|
161
161
|
if response.nil? #レスポンスが空の場合。時間だけ記録
|
162
162
|
@http_client.release
|
163
163
|
@http_client = nil
|
164
|
-
|
164
|
+
|
165
165
|
log "CONTENT_LENGTH:::", 0
|
166
166
|
@register.regist(@register_key, 0, response, @errorcount)
|
167
167
|
free
|
@@ -177,7 +177,7 @@ module InternetHakai
|
|
177
177
|
idx = url.index('/', 8) || url.size
|
178
178
|
path = url[idx, tmp ]
|
179
179
|
path = '/'+path if path[0,1]!='/'
|
180
|
-
@logger.run(response.body, 4) if response && @errorcount>0 && (response.content_type.include?('text') || response.content_type.include?('xml'))
|
180
|
+
@logger.run(response.body, 4) if response && @errorcount>0 && (response.content_type.include?('text') || response.content_type.include?('xml') || response.content_type.include?('json'))
|
181
181
|
on_redirect path
|
182
182
|
@redirect += 1
|
183
183
|
@redirect_url = path
|
@@ -229,7 +229,7 @@ module InternetHakai
|
|
229
229
|
log "RESPONSE_TIME:::",@rtime
|
230
230
|
#puts "on complete1.1: #{Time::now.usec/1000.to_f}"
|
231
231
|
|
232
|
-
response.body.force_encoding(@opt['encoding']) if @ruby19 and (response.content_type.include?('text') || response.content_type.include?('xml'))
|
232
|
+
response.body.force_encoding(@opt['encoding']) if @ruby19 and (response.content_type.include?('text') || response.content_type.include?('xml') || response.content_type.include?('json'))
|
233
233
|
if(@opt["scan"])
|
234
234
|
check_scan response.body, @opt["scan"]
|
235
235
|
end
|
@@ -245,7 +245,7 @@ module InternetHakai
|
|
245
245
|
@debug_msgs << "++++++++++++++++++++++++++++++++++++++\n"
|
246
246
|
@logger.run(@debug_msgs.join("\n")+"\n",3)
|
247
247
|
@debug_msgs = []
|
248
|
-
@logger.run(response.body, 4) if response && (response.content_type.include?('text') || response.content_type.include?('xml'))
|
248
|
+
@logger.run(response.body, 4) if response && (response.content_type.include?('text') || response.content_type.include?('xml') || response.content_type.include?('json'))
|
249
249
|
@logger.run("\r\n+++++++++++++++++++++++++++++++\n", 4)
|
250
250
|
ensure
|
251
251
|
free #絶対freeを呼ぶ!
|
@@ -15,7 +15,11 @@ module InternetHakai
|
|
15
15
|
require 'rev'
|
16
16
|
require 'internethakai/hakairev'
|
17
17
|
#TimeRegistProcess::run
|
18
|
-
@config['
|
18
|
+
if @config['ssl']
|
19
|
+
@config['http_client'] = 'RevSslClient'
|
20
|
+
else
|
21
|
+
@config['http_client'] = 'RevHttpClient'
|
22
|
+
end
|
19
23
|
@config['scenario_executer'] = 'NonBlockScenarioExecuter'
|
20
24
|
@config['request_pool'] = 'RequestPoolNonThread'
|
21
25
|
@config['queue'] = 'TaskQueue'
|
@@ -121,7 +125,7 @@ module InternetHakai
|
|
121
125
|
@scenarios.each do |sc|
|
122
126
|
sc.init
|
123
127
|
end
|
124
|
-
Thread.abort_on_exception
|
128
|
+
Thread.abort_on_exception
|
125
129
|
@scenario_handler.set_on_turn_complete &method(:on_complete)
|
126
130
|
1.upto(@config["max_request"]) do |th_cnt|
|
127
131
|
@threads[th_cnt] = Thread::new(th_cnt) do |th_cnt|
|
@@ -359,4 +359,64 @@ module InternetHakai
|
|
359
359
|
@client_queue.collect(self)
|
360
360
|
end
|
361
361
|
end
|
362
|
+
class RevSslClient < RevHttpClient
|
363
|
+
require 'rev/ssl'
|
364
|
+
include Rev::SSL
|
365
|
+
def reconnect
|
366
|
+
super
|
367
|
+
context = respond_to?(:ssl_context) ? ssl_context : OpenSSL::SSL::SSLContext.new
|
368
|
+
|
369
|
+
@_ssl_socket = Rev::SSL::IO.new(@_io, context)
|
370
|
+
@_ssl_init = proc { @_ssl_socket.connect_nonblock }
|
371
|
+
@__ssl_inited = true
|
372
|
+
|
373
|
+
begin
|
374
|
+
@_ssl_init.call
|
375
|
+
ssl_init_complete
|
376
|
+
rescue Rev::SSL::IO::ReadAgain
|
377
|
+
enable unless enabled?
|
378
|
+
rescue Rev::SSL::IO::WriteAgain
|
379
|
+
return
|
380
|
+
rescue OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::EPIPE
|
381
|
+
close
|
382
|
+
rescue => ex
|
383
|
+
if respond_to? :on_ssl_error
|
384
|
+
on_ssl_error(ex)
|
385
|
+
else raise ex
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
def on_writable
|
390
|
+
begin
|
391
|
+
nbytes = @_ssl_socket.write_nonblock @_write_buffer.to_str
|
392
|
+
rescue Errno::EAGAIN, Rev::SSL::IO::WriteAgain, Rev::SSL::IO::ReadAgain
|
393
|
+
return
|
394
|
+
rescue OpenSSL::SSL::SSLError, Errno::EPIPE, Errno::ECONNRESET
|
395
|
+
close
|
396
|
+
return
|
397
|
+
end
|
398
|
+
@_write_buffer.read(nbytes)
|
399
|
+
|
400
|
+
if @_write_buffer.empty?
|
401
|
+
disable_write_watcher
|
402
|
+
on_write_complete
|
403
|
+
end
|
404
|
+
end
|
405
|
+
def on_readable
|
406
|
+
begin
|
407
|
+
on_read @_ssl_socket.read_nonblock(Rev::IO::INPUT_SIZE)
|
408
|
+
rescue Errno::EAGAIN, Rev::SSL::IO::ReadAgain
|
409
|
+
return
|
410
|
+
rescue OpenSSL::SSL::SSLError, Errno::ECONNRESET, EOFError
|
411
|
+
close
|
412
|
+
end
|
413
|
+
end
|
414
|
+
def on_connect
|
415
|
+
unless @__ssl_inited
|
416
|
+
ssl_client_start
|
417
|
+
@__ssl_inited = true
|
418
|
+
end
|
419
|
+
super
|
420
|
+
end
|
421
|
+
end
|
362
422
|
end
|
@@ -33,6 +33,10 @@ module InternetHakai
|
|
33
33
|
def prepare_config
|
34
34
|
baseconfig = @config
|
35
35
|
basehost, baseport, = Util::parse_url(baseconfig['domain'])
|
36
|
+
if baseconfig['domain'].index('https://')==0
|
37
|
+
baseconfig['ssl'] = true
|
38
|
+
baseport = 443
|
39
|
+
end
|
36
40
|
basehostaddress = IPSocket::getaddress(basehost)
|
37
41
|
baseconfig['host'] = basehostaddress
|
38
42
|
baseconfig['host_name'] = basehost unless baseconfig['host_name']
|
@@ -130,7 +134,7 @@ module InternetHakai
|
|
130
134
|
@config['hosts'] = hosts
|
131
135
|
#concurrency はデフォルトでスレッドと同じ
|
132
136
|
if !@config.has_key?('max_scenario') || @config['max_scenario'] < @config['max_request']
|
133
|
-
@config['max_scenario'] = @config['max_request']
|
137
|
+
@config['max_scenario'] = @config['max_request']
|
134
138
|
end
|
135
139
|
@config['max_scenario'] = 1 if @config['max_scenario'] <= 0
|
136
140
|
|
data/lib/internethakai.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 5
|
9
|
+
version: 0.2.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- takada-at
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2012-04-12 00:00:00 +09:00
|
18
18
|
default_executable: internethakai
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|