Skip to content

Commit

Permalink
discontinued using Net::HTTP.version_1_1. #107
Browse files Browse the repository at this point in the history
	* removed HTTP.version_1_1.
	* used URI class to parse url.
  • Loading branch information
tdtds committed Nov 2, 2011
1 parent 6fac68c commit 844a660
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2011-11-02 TADA Tadashi <t@tdtds.jp>
* plugin/ping.rb: discontinued using Net::HTTP.version_1_1.

2011-10-30 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>

* tdiary/dispatcher/index_main.rb: bugfix http header when status is NOT_MODIFIED.
Expand Down
20 changes: 8 additions & 12 deletions misc/plugin/ping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,18 @@ def ping( list )

require 'net/http'
require 'timeout'
Net::HTTP.version_1_1
threads = []
list.each do |url|
threads << Thread.start( url, xml ) do |url, xml|
if %r|^http://([^/]+)(.*)$| =~ url then
begin
request = $2.empty? ? '/' : $2
host, port = $1.split( /:/, 2 )
port = '80' unless port
timeout(@conf['ping.timeout'].to_i) do
Net::HTTP.start( host.untaint, port.to_i ) do |http|
response, = http.post( request, xml, 'Content-Type' => 'text/xml' )
end
u = URI::parse( url.untaint )
next unless u.host
threads << Thread.start( u, xml ) do |u, xml|
begin
timeout( @conf['ping.timeout'].to_i ) do
Net::HTTP.start( u.host, u.port ) do |http|
http.post( u.path, xml, 'Content-Type' => 'text/xml' )
end
rescue Exception,Timeout::Error
end
rescue Exception,Timeout::Error
end
end
end
Expand Down

0 comments on commit 844a660

Please sign in to comment.