- Timestamp:
- 11/26/08 04:35:02 (4 years ago)
- Location:
- lang/ruby/enokidu_antenna
- Files:
-
- 2 modified
-
enokidu.rb (modified) (7 diffs)
-
enokidu_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/enokidu_antenna/enokidu.rb
r24822 r24890 32 32 @timeout = options[:timeout] || 30 33 33 @debug = options[:debug] || false 34 @request = Request.new(:timeout => @timeout, :debug => @debug)34 @request = Request.new(:timeout => @timeout, :debug => @debug) 35 35 end 36 36 37 37 def detective(options = {}) 38 page = options[:page]38 page = options[:page] 39 39 40 40 page.body ||= '' … … 76 76 class Request 77 77 def initialize(options = {}) 78 @http_header = {'User-Agent' => Enokidu::UserAgent::NAME, 'Connection' => 'close'} 78 @http_header = { 79 'User-Agent' => "#{Enokidu::UserAgent::NAME}/#{Enokidu::UserAgent::VERSION}".gsub(/:+/, ''), 80 'Connection' => 'close' 81 } 79 82 @timeout = options[:timeout] || 30 80 83 @debug = options[:debug] || false … … 114 117 115 118 # ロケーションが空または不完全な場合 116 if !location.empty? and !location.match(%r[^http ://])119 if !location.empty? and !location.match(%r[^https?://]) 117 120 uri = URI.parse(old_uri) 118 121 path, query = location.split('?') … … 136 139 if page.title.empty? 137 140 debug_print "get page title" 138 page.title = body.scan(/<title >([^<]*)/im).to_s.strip141 page.title = body.scan(/<title(?:\s[^>]*)?>\s*([^<]*)/im).to_s.rstrip 139 142 page.title = 'no title' if page.title.empty? 140 143 end … … 144 147 else 145 148 body 146 end.gsub(/<[^>]*>|\s |\n/, '')149 end.gsub(/<[^>]*>|\s+/, '') 147 150 148 151 # 更新チェック … … 189 192 end 190 193 191 # E tag で更新チェック194 # ETag で更新チェック 192 195 if !lm and etag and page.etag != etag 193 196 page.etag = etag … … 196 199 end 197 200 198 # Last-Modified も E tag も使えない201 # Last-Modified も ETag も使えない 199 202 raise InvalidHeadResponse unless lm or etag 200 203 -
lang/ruby/enokidu_antenna/enokidu_test.rb
r24822 r24890 46 46 before_modified_at = page.last_modified_at 47 47 page = detective(:page => page) 48 48 49 49 assert page.updated? 50 50 assert before_modified_at < page.last_modified_at
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)