rubyslippers 1.03 → 1.04
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.txt +3 -0
- data/bin/rubyslippers +0 -0
- data/code/01rwdcore/01rwdcore.rb +0 -0
- data/code/01rwdcore/02helptexthashbegin.rb +0 -0
- data/code/01rwdcore/03helptexthash.rb +0 -0
- data/code/01rwdcore/04helptextend.rb +0 -0
- data/code/01rwdcore/jumplinkcommand.rb +0 -0
- data/code/01rwdcore/openhelpwindow.rb +0 -0
- data/code/01rwdcore/returntomain.rb +0 -0
- data/code/01rwdcore/rundocuments.rb +0 -0
- data/code/01rwdcore/runeditconfiguration.rb +0 -0
- data/code/01rwdcore/runhelpabout.rb +0 -0
- data/code/01rwdcore/rwdtinkerversion.rb +0 -0
- data/code/01rwdcore/rwdwindowreturn.rb +0 -0
- data/code/01rwdcore/selectiontab.rb +0 -0
- data/code/01rwdcore/test_cases.rb +0 -0
- data/code/01rwdcore/test_harness.rb +0 -0
- data/code/01rwdcore/uploadreturns.rb +0 -0
- data/code/superant.com.rubyslippers/execgemserve.rb +0 -0
- data/code/superant.com.rubyslippers/gemcommands.rb +0 -0
- data/code/superant.com.rubyslippers/gemenvironment.rb +0 -0
- data/code/superant.com.rubyslippers/gemfilesinstalled.rb +0 -0
- data/code/superant.com.rubyslippers/gemserve.rb +0 -0
- data/code/superant.com.rubyslippers/gemwhich.rb +0 -0
- data/code/superant.com.rubyslippers/helptexthashrubyslippers.rb +0 -0
- data/code/superant.com.rubyslippers/installgem.rb +0 -0
- data/code/superant.com.rubyslippers/jumplinkupdate.rb +0 -0
- data/code/superant.com.rubyslippers/listgemdirs.rb +0 -0
- data/code/superant.com.rubyslippers/listgemrecord.rb +0 -0
- data/code/superant.com.rubyslippers/listgemremote.rb +0 -0
- data/code/superant.com.rubyslippers/listgemzips.rb +0 -0
- data/code/superant.com.rubyslippers/listinstalledgemsfiles.rb +0 -0
- data/code/superant.com.rubyslippers/loadconfigurationrecord.rb +0 -0
- data/code/superant.com.rubyslippers/loadconfigurationvariables.rb +0 -0
- data/code/superant.com.rubyslippers/openhelpwindowrubyslippers.rb +0 -0
- data/code/superant.com.rubyslippers/returntomain.rb +0 -0
- data/code/superant.com.rubyslippers/rubyslippershelpabout.rb +0 -0
- data/code/superant.com.rubyslippers/runrubyslippersmenu1.rb +0 -0
- data/code/superant.com.rubyslippers/runrubyslipperswindow.rb +0 -0
- data/code/superant.com.rubyslippers/saveconfigurationrecord.rb +0 -0
- data/code/superant.com.rubyslippers/test_cases.rb +0 -0
- data/code/superant.com.rubyslippers/viewgemdata.rb +0 -0
- data/code/superant.com.rubyslippers/viewrubyslippersconfiguration.rb +0 -0
- data/code/superant.com.rubyslippersbackwindow/changegemspecdata.rb +0 -0
- data/code/superant.com.rubyslippersbackwindow/clearscreendisplay.rb +0 -0
- data/code/superant.com.rubyslippersbackwindow/copygemspecdata.rb +0 -0
- data/code/superant.com.rubyslippersbackwindow/creategem.rb +0 -0
- data/code/superant.com.rubyslippersbackwindow/creategemspecrecord.rb +0 -0
- data/code/superant.com.rubyslippersbackwindow/deletegemspecrecord.rb +0 -0
- data/code/superant.com.rubyslippersbackwindow/listgemdir.rb +0 -0
- data/code/superant.com.rubyslippersbackwindow/listgemdirectories.rb +0 -0
- data/code/superant.com.rubyslippersbackwindow/listgemspecrecord.rb +0 -0
- data/code/superant.com.rubyslippersbackwindow/loadgemspecrecord.rb +0 -0
- data/code/superant.com.rubyslippersbackwindow/viewgemspecdata.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/controlclient.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/diagnostictab.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/helptexthashtinkerwin2.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/installapplet.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/installgemapplet.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/installremotegem.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/listgemdirs.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/listgemzips.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/listinstalledfiles.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/listzips.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/loadconfigurationrecord.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/loadconfigurationvariables.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/network.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/openappletname.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/openhelpwindowtinkerwin2.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/remotegemlist.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/removeapplet.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/runremoteinstall.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/runrwdtinkerbackwindow.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/rwdtinkerwin2version.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/saveconfigurationrecord.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/viewappletcontents.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/viewgemappletcontents.rb +0 -0
- data/code/zz0applicationend/zz0end.rb +0 -0
- data/configuration/language.dist +0 -0
- data/configuration/rubyslippers.dist +2 -2
- data/configuration/rwdapplicationidentity.dist +0 -0
- data/configuration/rwdtinker.dist +2 -2
- data/configuration/tinkerwin2variables.dist +0 -0
- data/ev/browser.rb +24 -10
- data/ev/ftools.rb +23 -19
- data/ev/mime.rb +328 -0
- data/ev/net.rb +154 -38
- data/ev/ruby.rb +96 -26
- data/ev/rwd.rb +162 -89
- data/ev/sgml.rb +1 -1
- data/ev/thread.rb +0 -0
- data/ev/tree.rb +33 -5
- data/ev/xml.rb +97 -0
- data/extras/rconftool.rb +0 -0
- data/extras/zip/ioextras.rb +0 -0
- data/extras/zip/stdrubyext.rb +0 -0
- data/extras/zip/tempfile_bugfixed.rb +0 -0
- data/extras/zip/zip.rb +0 -0
- data/extras/zip/zipfilesystem.rb +0 -0
- data/extras/zip/ziprequire.rb +0 -0
- data/gui/00coreguibegin/applicationguitop.rwd +0 -0
- data/gui/frontwindow0/superant.com.rubyslippers/25gemcommands.rwd +0 -0
- data/gui/frontwindow0/superant.com.rubyslippers/30viewgemdata.rwd +0 -0
- data/gui/frontwindow0/superant.com.rubyslippers/40listgemrecordfiles.rwd +0 -0
- data/gui/frontwindow0/superant.com.rubyslippers/60installgem.rwd +0 -0
- data/gui/frontwindow0/superant.com.rubyslippers/70listgemsremote.rwd +0 -0
- data/gui/frontwindow0/superant.com.rubyslippers/75gemwhich.rwd +0 -0
- data/gui/frontwindow0/superant.com.rubyslippers/85gemfilesinstalled.rwd +0 -0
- data/gui/frontwindow0/superant.com.rubyslippers/90gemserverscan.rwd +0 -0
- data/gui/frontwindowselectionbegin/selectiontabbegin/selectiontabbegin.rwd +0 -0
- data/gui/frontwindowselections/superant.com.rwdtinkerwin2selectiontab/jumplinkcommands.rwd +0 -0
- data/gui/frontwindowselectionzend/viewselectionzend/viewselectionend.rwd +0 -0
- data/gui/frontwindowtdocumentbegin/superant.com.documentsbegin/tt0documentbegin.rwd +0 -0
- data/gui/frontwindowtdocuments/superant.com.documents/uu5documents.rwd +0 -0
- data/gui/frontwindowtdocuments/superant.com.rubyslippersdocument/ui3rubyslippers.rwd +0 -0
- data/gui/frontwindowtdocuments/superant.com.rubyslippersdocument/ui4rubyslippers.rwd +0 -0
- data/gui/frontwindowtdocuments/superant.com.tinkerwin2documents/uu5documents.rwd +0 -0
- data/gui/frontwindowtdocumentzend/superant.com.documentsend/ww0documentend.rwd +0 -0
- data/gui/frontwindowz1end/frontwindowend/xx0rwdfirsttab.rwd +0 -0
- data/gui/helpaboutbegin/superant.com.helpaboutbegin/ya0helpscreenstart.rwd +0 -0
- data/gui/helpaboutinstalled/superant.com.rubyslippershelpabout/1rubyslippers.rwd +0 -0
- data/gui/helpaboutinstalled/superant.com.rubyslippershelpabout/2rubyslippers.rwd +0 -0
- data/gui/helpaboutinstalled/superant.com.rubyslippershelpabout/5version.rwd +0 -0
- data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/1appname.rwd +0 -0
- data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/3copyright.rwd +0 -0
- data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/5version.rwd +0 -0
- data/gui/helpaboutzend/superant.com.helpaboutend/helpscreenend.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/1appname.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/3viewgemspec.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/4listgemspecrecord.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/5editgemspecrecord.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/6buildgem.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/7viewgemdir.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/8gemcommands.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/92viewconfiguration.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/94rwddiagnostics.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/m90selectiontab.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/m95jumplinkcommands.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/m99selection.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rubyslippersbackwindow/zbackend.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/1appname.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/40rwdlistzips.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/45installremotezip.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/50rwdlistapplets.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/60editconfiguration.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/70rwddiagnostics.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/75rwdcontrol.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/81jumplinkcommands.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/9backend.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/1appname.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/9end.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.versionwindow/1appname.rwd +0 -0
- data/gui/zzcoreguiend/tinkerapplicationguiend/yy9rwdend.rwd +0 -0
- data/init.rb +0 -0
- data/installed/rwdviewlogo-0.4.inf +0 -0
- data/lang/en/rubyslippers/languagefile.rb +0 -0
- data/lang/en/rwdcore/languagefile.rb +0 -0
- data/lang/es/rubyslippers/languagefile.rb +0 -0
- data/lang/es/rwdcore/languagefile-es.rb +0 -0
- data/lang/jp/rubyslippers/languagefile.rb +0 -0
- data/lang/jp/rwdcore/languagefile.rb +0 -0
- data/lang/nl/rubyslippers/languagefile.rb +0 -0
- data/lang/nl/rwdcore/languagefile.rb +0 -0
- data/lib/temp.rb +0 -0
- data/rwd_files/GemDocuments.html +0 -0
- data/rwd_files/HowTo_RubySlippers.txt +3 -0
- data/rwd_files/HowTo_Tinker.txt +0 -0
- data/rwd_files/HowTo_TinkerWin2.txt +0 -0
- data/rwd_files/Readme.txt +0 -0
- data/rwd_files/favicon.ico +0 -0
- data/rwd_files/rdoc-style.css +0 -0
- data/rwd_files/remotegemlist.txt +0 -0
- data/rwd_files/rwdapplications.html +0 -0
- data/rwd_files/rwdindex.html +0 -0
- data/rwd_files/tinker.png +0 -0
- data/rwdconfig.dist +1 -1
- data/tests/RubyGauge.rb +0 -0
- data/tests/checkdepends.sh +0 -0
- data/tests/cleancnf.sh +0 -0
- data/tests/makedist.rb +0 -0
- data/tests/rdep.rb +0 -0
- data/tests/totranslate.lang +0 -0
- data/zips/rwdahelloworld-0.5.zip +0 -0
- metadata +244 -229
data/ev/net.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "ev/ruby"
|
2
2
|
require "ev/ftools"
|
3
|
+
require "ev/mime"
|
3
4
|
require "net/http"
|
4
5
|
require "socket"
|
5
6
|
require "uri"
|
@@ -13,11 +14,11 @@ file = "#{home}/.evnet"
|
|
13
14
|
if File.file?(file)
|
14
15
|
Hash.file(file).each do |k, v|
|
15
16
|
eval "$#{k} = '#{v}'" unless k=~ /^\#/
|
16
|
-
#$proxy_auth = [$proxy_auth].pack("m").chomp if k == "proxy_auth"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def uri2txt(s)
|
21
|
+
# ??? Werkt niet goed
|
21
22
|
i = s.index(/%[[:digit:]]{2}/)
|
22
23
|
while not i.nil?
|
23
24
|
s = s[0..(i-1)] + s[(i+1)..(i+2)].unpack('H2').shift.to_i.chr + s[(i+3)..-1]
|
@@ -147,6 +148,8 @@ class EVURI
|
|
147
148
|
rescue
|
148
149
|
end
|
149
150
|
|
151
|
+
@path = "/" if (not @path.nil? and @path.empty? and @protocol == "http")
|
152
|
+
|
150
153
|
@protocol = "" if @protocol.nil?
|
151
154
|
@userpass = "" if @userpass.nil?
|
152
155
|
@host = "" if @host.nil?
|
@@ -163,7 +166,7 @@ class EVURI
|
|
163
166
|
@port = @port.to_i
|
164
167
|
end
|
165
168
|
|
166
|
-
def +
|
169
|
+
def +(url2)
|
167
170
|
url1 = self.to_s
|
168
171
|
url2 = url2.to_s if url2.kind_of?(self.class)
|
169
172
|
|
@@ -174,7 +177,7 @@ class EVURI
|
|
174
177
|
protocol = @protocol
|
175
178
|
userpass = @userpass
|
176
179
|
host = @host
|
177
|
-
port = @port
|
180
|
+
port = @port
|
178
181
|
path = @path
|
179
182
|
vars = varstring
|
180
183
|
anchor = @anchor
|
@@ -196,6 +199,33 @@ class EVURI
|
|
196
199
|
return res
|
197
200
|
end
|
198
201
|
|
202
|
+
def localname
|
203
|
+
protocol = @protocol
|
204
|
+
userpass = @userpass
|
205
|
+
host = @host
|
206
|
+
port = @port
|
207
|
+
path = @path
|
208
|
+
vars = varstring
|
209
|
+
anchor = @anchor
|
210
|
+
|
211
|
+
protocol = nil if @protocol.empty?
|
212
|
+
userpass = nil if @userpass.empty?
|
213
|
+
host = nil if @host.empty?
|
214
|
+
port = nil if @port.zero?
|
215
|
+
path = nil if @path.empty?
|
216
|
+
vars = nil if @vars.empty?
|
217
|
+
anchor = nil if @anchor.empty?
|
218
|
+
|
219
|
+
path = "#{path}." if path =~ /[\/\\]$/
|
220
|
+
|
221
|
+
f = MD5.new(protocol.to_s + userpass.to_s + host.to_s + port.to_s + File.dirname(path.to_s) + vars.to_s).to_s
|
222
|
+
e = File.basename(path.to_s).gsub(/[^\w\.\-]/, "_").gsub(/_+/, "_")
|
223
|
+
res = f + "." + e
|
224
|
+
res.gsub!(/[^\w]+$/, "")
|
225
|
+
|
226
|
+
return res
|
227
|
+
end
|
228
|
+
|
199
229
|
def varstring
|
200
230
|
res = []
|
201
231
|
vars = @vars.dup
|
@@ -281,36 +311,52 @@ class HTTPClient
|
|
281
311
|
end
|
282
312
|
end
|
283
313
|
|
314
|
+
class NoAddressException < StandardError
|
315
|
+
end
|
316
|
+
|
317
|
+
def self.getaddress(host)
|
318
|
+
if not @@hosts.include?(host)
|
319
|
+
@@hosts[host] = ""
|
320
|
+
evtimeout(5) do # ??? Doet 'ut niet?...
|
321
|
+
@@hosts[host] = IPSocket.getaddress(host)
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
raise NoAddressException, host if @@hosts[host].empty?
|
326
|
+
|
327
|
+
@@hosts[host]
|
328
|
+
end
|
329
|
+
|
284
330
|
def self.head(uri, form={}, recursive=true)
|
285
331
|
header = Header.new(nil)
|
286
332
|
|
287
333
|
begin
|
288
334
|
while not uri.nil?
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
335
|
+
uri = EVURI.new(uri) if uri.kind_of? String
|
336
|
+
host = uri.host
|
337
|
+
port = uri.port
|
338
|
+
|
339
|
+
if $proxy.nil? or $proxy.empty? or host == "localhost"
|
293
340
|
io = nil
|
294
341
|
|
295
342
|
@@mutex.synchronize do
|
296
|
-
|
297
|
-
io = TCPSocket.new(@@hosts[host], port.zero? ? 80 : port)
|
343
|
+
io = TCPSocket.new(getaddress(host), port.zero? ? 80 : port)
|
298
344
|
end
|
299
345
|
|
300
346
|
io.write("HEAD #{uri.path or '/'}#{uri.varstring.empty? ? '' : '?' + uri.varstring} HTTP/1.0\r\nHost: #{host}\r\n\r\n")
|
301
347
|
else
|
302
348
|
proxy = EVURI.new($proxy)
|
303
|
-
|
304
|
-
port = proxy.port
|
305
|
-
|
306
|
-
io = TCPSocket.new(host, port.zero? ? 8080 : port)
|
349
|
+
io = TCPSocket.new(proxy.host, proxy.port.zero? ? 8080 : proxy.port)
|
307
350
|
|
308
351
|
io.write("HEAD #{uri} HTTP/1.0\r\n#{"Proxy-Authorization: Basic "+$proxy_auth+"\r\n" if not $proxy_auth.nil?}\r\n\r\n")
|
309
352
|
end
|
310
353
|
|
311
354
|
io.close_write
|
312
355
|
|
313
|
-
res
|
356
|
+
res = io.read
|
357
|
+
|
358
|
+
io.close_read
|
359
|
+
|
314
360
|
header, data = nil, nil
|
315
361
|
header, data = res.split(/\r*\n\r*\n/, 2) if not res.nil?
|
316
362
|
header = Header.new(header)
|
@@ -321,14 +367,23 @@ class HTTPClient
|
|
321
367
|
uri = nil
|
322
368
|
end
|
323
369
|
end
|
324
|
-
rescue
|
370
|
+
rescue Errno::ECONNRESET, Errno::EHOSTUNREACH => e
|
371
|
+
$stderr.puts e.message
|
372
|
+
sleep 1
|
373
|
+
retry
|
374
|
+
rescue Errno::ECONNREFUSED => e
|
375
|
+
data = nil
|
376
|
+
rescue NoAddressException => e
|
377
|
+
$stderr.puts e.message
|
325
378
|
header = Header.new(nil)
|
326
379
|
end
|
327
380
|
|
381
|
+
GC.start
|
382
|
+
|
328
383
|
return header
|
329
384
|
end
|
330
385
|
|
331
|
-
def self.get(uri, form={})
|
386
|
+
def self.get(uri, httpheader={}, form={})
|
332
387
|
post = Array.new
|
333
388
|
form.each_pair do |var, value|
|
334
389
|
post << "#{var.to_html}=#{value.to_html}"
|
@@ -339,15 +394,14 @@ class HTTPClient
|
|
339
394
|
|
340
395
|
begin
|
341
396
|
while not uri.nil?
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
port = uri.port
|
397
|
+
uri = EVURI.new(uri) if uri.kind_of? String
|
398
|
+
host = uri.host
|
399
|
+
port = uri.port
|
346
400
|
|
401
|
+
if $proxy.nil? or $proxy.empty? or host == "localhost"
|
347
402
|
io = nil
|
348
403
|
@@mutex.synchronize do
|
349
|
-
|
350
|
-
io = TCPSocket.new(@@hosts[host], port.zero? ? 80 : port)
|
404
|
+
io = TCPSocket.new(getaddress(host), port.zero? ? 80 : port)
|
351
405
|
end
|
352
406
|
|
353
407
|
if post.empty?
|
@@ -357,10 +411,7 @@ class HTTPClient
|
|
357
411
|
end
|
358
412
|
else
|
359
413
|
proxy = EVURI.new($proxy)
|
360
|
-
|
361
|
-
port = proxy.port
|
362
|
-
|
363
|
-
io = TCPSocket.new(host, port.zero? ? 8080 : port)
|
414
|
+
io = TCPSocket.new(proxy.host, proxy.port.zero? ? 8080 : proxy.port)
|
364
415
|
|
365
416
|
if post.empty?
|
366
417
|
io.write "GET %s HTTP/1.0\r\n" % uri
|
@@ -370,22 +421,32 @@ class HTTPClient
|
|
370
421
|
end
|
371
422
|
|
372
423
|
io.write "Host: %s\r\n" % host
|
373
|
-
io.write "User-Agent:
|
374
|
-
io.write "Proxy-Authorization: Basic %s\r\n" % $proxy_auth
|
424
|
+
io.write "User-Agent: xyz\r\n"
|
425
|
+
io.write "Proxy-Authorization: Basic %s\r\n" % $proxy_auth unless $proxy_auth.nil?
|
375
426
|
#io.write "Accept-Encoding: deflate\r\n"
|
376
|
-
#io.write "
|
427
|
+
#io.write "Accept-Charset: ISO-8859-1\r\n"
|
428
|
+
io.write "Connection: close\r\n"
|
377
429
|
io.write "Content-Type: application/x-www-form-urlencoded\r\n" unless post.empty?
|
378
430
|
io.write "Content-Length: %s\r\n" % post.length unless post.empty?
|
431
|
+
httpheader.each do |k, v|
|
432
|
+
$stderr.puts "%s: %s\r\n" % [k, v]
|
433
|
+
io.write "%s: %s\r\n" % [k, v]
|
434
|
+
end
|
379
435
|
io.write "\r\n"
|
380
436
|
io.write post unless post.empty?
|
381
437
|
|
382
438
|
io.close_write
|
383
439
|
|
384
440
|
res = io.read
|
441
|
+
|
442
|
+
io.close_read
|
443
|
+
|
385
444
|
header, data = nil, nil
|
386
445
|
header, data = res.split(/\r*\n\r*\n/, 2) if not res.nil?
|
387
446
|
|
388
447
|
header = Header.new(header)
|
448
|
+
length = header.header["content-length"]
|
449
|
+
data = "" if length == "0"
|
389
450
|
|
390
451
|
if header.header["location"] != uri.to_s
|
391
452
|
uri = EVURI.new(uri) + header.header["location"]
|
@@ -397,12 +458,25 @@ class HTTPClient
|
|
397
458
|
data = Chunk.new(data).to_s if not data.nil?
|
398
459
|
end
|
399
460
|
|
461
|
+
#if header.header["content-encoding"] == "gzip"
|
462
|
+
#data = "gzip -d".exec(data) if not data.nil?
|
463
|
+
#end
|
464
|
+
|
400
465
|
data = nil unless header.code == 200
|
401
466
|
end
|
402
|
-
rescue
|
467
|
+
rescue Errno::ECONNRESET, Errno::EHOSTUNREACH => e
|
468
|
+
$stderr.puts e.message
|
469
|
+
sleep 1
|
470
|
+
retry
|
471
|
+
rescue Errno::ECONNREFUSED => e
|
472
|
+
data = nil
|
473
|
+
rescue NoAddressException, Errno::ECONNREFUSED => e
|
474
|
+
$stderr.puts e.message
|
403
475
|
data = nil
|
404
476
|
end
|
405
477
|
|
478
|
+
GC.start
|
479
|
+
|
406
480
|
return data
|
407
481
|
end
|
408
482
|
|
@@ -422,7 +496,7 @@ class HTTPClient
|
|
422
496
|
file = "#{dir}/#{hash}"
|
423
497
|
data = nil
|
424
498
|
|
425
|
-
|
499
|
+
File.mkpath(dir)
|
426
500
|
|
427
501
|
expire = 356*24*60*60
|
428
502
|
|
@@ -447,7 +521,7 @@ end
|
|
447
521
|
class RequestGet < Hash
|
448
522
|
def initialize(data)
|
449
523
|
CGI.parse(data).each do |k, v|
|
450
|
-
self[k] = v
|
524
|
+
self[k] = v
|
451
525
|
end
|
452
526
|
end
|
453
527
|
end
|
@@ -455,7 +529,7 @@ end
|
|
455
529
|
class RequestPost < Hash
|
456
530
|
def initialize(data)
|
457
531
|
CGI.parse(data).each do |k, v|
|
458
|
-
self[k] = v
|
532
|
+
self[k] = v
|
459
533
|
end
|
460
534
|
end
|
461
535
|
end
|
@@ -493,6 +567,8 @@ class Request < Hash
|
|
493
567
|
attr_reader :request
|
494
568
|
attr_reader :cookies
|
495
569
|
attr_reader :vars
|
570
|
+
attr_reader :user
|
571
|
+
attr_writer :user
|
496
572
|
|
497
573
|
def initialize(io)
|
498
574
|
@io = io
|
@@ -562,6 +638,7 @@ end
|
|
562
638
|
|
563
639
|
class Response < Hash
|
564
640
|
attr_writer :response
|
641
|
+
attr_writer :file
|
565
642
|
attr_reader :cookies
|
566
643
|
attr_reader :stop
|
567
644
|
attr_reader :at_stop
|
@@ -574,10 +651,20 @@ class Response < Hash
|
|
574
651
|
@syncd = false
|
575
652
|
@stop = false
|
576
653
|
@at_stop = lambda{}
|
654
|
+
@file = nil
|
577
655
|
end
|
578
656
|
|
579
657
|
def flush
|
580
658
|
sync
|
659
|
+
|
660
|
+
if @file
|
661
|
+
File.open(@file, "rb") do |f|
|
662
|
+
while data = f.read(10_000)
|
663
|
+
@io.write data
|
664
|
+
end
|
665
|
+
end
|
666
|
+
end
|
667
|
+
|
581
668
|
@io.close
|
582
669
|
end
|
583
670
|
|
@@ -595,6 +682,21 @@ class Response < Hash
|
|
595
682
|
end
|
596
683
|
|
597
684
|
def sync
|
685
|
+
size = (@data or "").length
|
686
|
+
|
687
|
+
if @file
|
688
|
+
ext = @file.scan(/\.[^\.]*$/)
|
689
|
+
ext = ext.shift
|
690
|
+
ext = ext[1..-1] unless ext.nil?
|
691
|
+
mimetype = EVMime::MimeType[ext]
|
692
|
+
|
693
|
+
self["Content-Type"] = mimetype unless mimetype.nil?
|
694
|
+
|
695
|
+
size += File.size(@file) if File.file?(@file)
|
696
|
+
end
|
697
|
+
|
698
|
+
self["Content-Length"] = size
|
699
|
+
|
598
700
|
@io.write("#{to_s}\r\n") unless @syncd
|
599
701
|
@io.write(@data)
|
600
702
|
@data = ""
|
@@ -605,6 +707,10 @@ class Response < Hash
|
|
605
707
|
@data << s
|
606
708
|
end
|
607
709
|
|
710
|
+
def clean
|
711
|
+
@data = ""
|
712
|
+
end
|
713
|
+
|
608
714
|
def inspect
|
609
715
|
"(Response: %s)" % [@response, @data].join(", ")
|
610
716
|
end
|
@@ -640,7 +746,7 @@ class HTTPServer
|
|
640
746
|
count = 0
|
641
747
|
|
642
748
|
at_exit do
|
643
|
-
|
749
|
+
#$stderr.puts "Received #{count} requests"
|
644
750
|
end
|
645
751
|
|
646
752
|
serverthread =
|
@@ -678,7 +784,7 @@ class HTTPServer
|
|
678
784
|
end
|
679
785
|
|
680
786
|
if (not remote) or (remote and (auth.nil? or auth.empty? or authenticate(auth, realm, req, resp)))
|
681
|
-
$stderr.puts "#{count2}
|
787
|
+
$stderr.puts "#{count2} #{Time.new.strftime("%Y-%m-%d %H:%M:%S")} #{ip} #{req.user} #{req.request.to_s.strip}"
|
682
788
|
|
683
789
|
begin
|
684
790
|
yield(req, resp)
|
@@ -687,6 +793,16 @@ class HTTPServer
|
|
687
793
|
$stderr.puts e.class.to_s + ": " + e.message
|
688
794
|
$stderr.puts e.backtrace.collect{|s| "\t"+s}.join("\n")
|
689
795
|
end
|
796
|
+
resp["Content-Type"] = "text/plain"
|
797
|
+
resp.response = "HTTP/1.0 200 ???"
|
798
|
+
resp.clean
|
799
|
+
resp << e.class.to_s + ": " + e.message
|
800
|
+
resp << "\n"
|
801
|
+
resp << "\n"
|
802
|
+
resp << e.backtrace.collect{|s| "\t"+s}.join("\n")
|
803
|
+
resp << "\n"
|
804
|
+
resp << "\n"
|
805
|
+
resp << "(You can use the back button and stop the application properly, if appropriate.)"
|
690
806
|
end
|
691
807
|
|
692
808
|
stop = true if resp.stop?
|
@@ -738,13 +854,13 @@ class HTTPServer
|
|
738
854
|
|
739
855
|
ok = (auths.include?(u) and auths[u] == p)
|
740
856
|
|
741
|
-
|
742
|
-
|
743
|
-
else
|
857
|
+
unless ok
|
744
858
|
resp["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
|
745
859
|
resp.response = "HTTP/1.0 401 Unauthorized"
|
746
860
|
end
|
747
861
|
|
862
|
+
req.user = u
|
863
|
+
|
748
864
|
return ok
|
749
865
|
end
|
750
866
|
end
|
data/ev/ruby.rb
CHANGED
@@ -18,14 +18,16 @@ tekens23 = tekens + "'"
|
|
18
18
|
|
19
19
|
tekens31 = '\w\s\r\n'
|
20
20
|
|
21
|
-
RegExpStringWord = "([#{tekens11}]+)" ; RegExpWord
|
22
|
-
RegExpStringWord2 = "([#{tekens21}]([#{tekens22}]*[#{tekens23}])?)" ; RegExpWord2
|
23
|
-
RegExpStringText = "([#{tekens31}]+)" ; RegExpText
|
24
|
-
RegExpStringFile = '(\w[\w\.\-]*)' ; RegExpFile
|
25
|
-
RegExpStringEmail = '([\w\-\.]+@[\w\-\.]+)' ; RegExpEmail
|
26
|
-
RegExpStringURL = '(\w+:\/\/[\w\.\-]+(:\d*)?\/[\w\.\-\/\#\?\=\%]*)' ; RegExpURL
|
27
|
-
RegExpStringPrint = '([\w \t\r\n\`\~\!\@\#\$\%\^\&\*\(\)\-\+\=\[\]\{\}\;\:\'\"\,\.\/\<\>\?\\\|]+)' ; RegExpPrint
|
28
|
-
RegExpStringDiff = '(^[\-\+]([^\-\+].*)?)' ; RegExpDiff
|
21
|
+
RegExpStringWord = "([#{tekens11}]+)" ; RegExpWord = Regexp.new(RegExpStringWord)
|
22
|
+
RegExpStringWord2 = "([#{tekens21}]([#{tekens22}]*[#{tekens23}])?)" ; RegExpWord2 = Regexp.new(RegExpStringWord2)
|
23
|
+
RegExpStringText = "([#{tekens31}]+)" ; RegExpText = Regexp.new(RegExpStringText)
|
24
|
+
RegExpStringFile = '(\w[\w\.\-]*)' ; RegExpFile = Regexp.new(RegExpStringFile)
|
25
|
+
RegExpStringEmail = '([\w\-\.]+@[\w\-\.]+)' ; RegExpEmail = Regexp.new(RegExpStringEmail)
|
26
|
+
RegExpStringURL = '(\w+:\/\/[\w\.\-]+(:\d*)?\/[\w\.\-\/\#\?\=\%]*)' ; RegExpURL = Regexp.new(RegExpStringURL)
|
27
|
+
RegExpStringPrint = '([\w \t\r\n\`\~\!\@\#\$\%\^\&\*\(\)\-\+\=\[\]\{\}\;\:\'\"\,\.\/\<\>\?\\\|]+)' ; RegExpPrint = Regexp.new(RegExpStringPrint)
|
28
|
+
RegExpStringDiff = '(^[\-\+]([^\-\+].*)?)' ; RegExpDiff = Regexp.new(RegExpStringDiff)
|
29
|
+
RegExpStringHTHLink = '(`[\w\,]*\ba\b[^`]*`)' ; RegExpHTHLink = Regexp.new(RegExpStringHTHLink)
|
30
|
+
RegExpStringHTHSpecial = '(`[^`]*`)' ; RegExpHTHSpecial = Regexp.new(RegExpStringHTHSpecial)
|
29
31
|
|
30
32
|
module Enumerable
|
31
33
|
def deep_dup
|
@@ -64,6 +66,10 @@ class Numeric
|
|
64
66
|
def to_fs
|
65
67
|
to_f
|
66
68
|
end
|
69
|
+
|
70
|
+
def to_html(eolconversion=true)
|
71
|
+
self.to_s.to_html(eolconversion)
|
72
|
+
end
|
67
73
|
end
|
68
74
|
|
69
75
|
class Integer
|
@@ -211,8 +217,8 @@ class String
|
|
211
217
|
end
|
212
218
|
|
213
219
|
def splitwords(tokens=[])
|
214
|
-
tokens
|
215
|
-
res
|
220
|
+
tokens = [tokens] unless tokens.kind_of?(Array)
|
221
|
+
res = []
|
216
222
|
|
217
223
|
self.splitblocks(["'", "'"], ['"', '"']).each do |type, s|
|
218
224
|
case type
|
@@ -437,13 +443,14 @@ class Array
|
|
437
443
|
end
|
438
444
|
|
439
445
|
def format(format)
|
446
|
+
format = format.gsub(/\s/, "")
|
440
447
|
res = []
|
441
448
|
|
442
449
|
[format.length, self.length].min.times do |n|
|
443
|
-
case format[n].chr
|
444
|
-
when "i" then
|
445
|
-
when "s" then
|
446
|
-
|
450
|
+
case format[n].chr.downcase
|
451
|
+
when "i" then res << self[n].to_i
|
452
|
+
when "s" then res << self[n].to_s
|
453
|
+
else res << self[n]
|
447
454
|
end
|
448
455
|
end
|
449
456
|
|
@@ -540,6 +547,36 @@ class Array
|
|
540
547
|
def ids
|
541
548
|
collect{|e| e.ids}
|
542
549
|
end
|
550
|
+
|
551
|
+
def rotate
|
552
|
+
raise "Array has to be 2D (An Array of Arrays)." unless self.dup.delete_if{|a| a.kind_of?(Array)}.empty?
|
553
|
+
|
554
|
+
res = []
|
555
|
+
|
556
|
+
self[0].length.times do |x|
|
557
|
+
a = []
|
558
|
+
|
559
|
+
self.length.times do |y|
|
560
|
+
a << self[y][x]
|
561
|
+
end
|
562
|
+
|
563
|
+
res << a
|
564
|
+
end
|
565
|
+
|
566
|
+
res
|
567
|
+
end
|
568
|
+
|
569
|
+
def to_h
|
570
|
+
raise "Array has to be 2D (An Array of Arrays)." unless self.dup.delete_if{|a| a.kind_of?(Array)}.empty?
|
571
|
+
|
572
|
+
res = {}
|
573
|
+
|
574
|
+
self.each do |k, v, *rest|
|
575
|
+
res[k] = v
|
576
|
+
end
|
577
|
+
|
578
|
+
res
|
579
|
+
end
|
543
580
|
end
|
544
581
|
|
545
582
|
class Hash
|
@@ -699,7 +736,11 @@ def trap(signal)
|
|
699
736
|
end
|
700
737
|
|
701
738
|
def linux?
|
702
|
-
not
|
739
|
+
not (target_os.downcase =~ /linux/).nil?
|
740
|
+
end
|
741
|
+
|
742
|
+
def darwin?
|
743
|
+
not (target_os.downcase =~ /darwin/).nil?
|
703
744
|
end
|
704
745
|
|
705
746
|
def windows?
|
@@ -727,8 +768,9 @@ def temp
|
|
727
768
|
end
|
728
769
|
|
729
770
|
def stdtmp
|
730
|
-
$stderr = $stdout = File.new("#{temp}/ruby.#{Process.pid}.log", "a")
|
771
|
+
$stderr = $stdout = File.new("#{temp}/ruby.#{Process.pid}.log", "a")
|
731
772
|
end
|
773
|
+
stdtmp if defined?(RUBYSCRIPT2EXE) and (RUBYSCRIPT2EXE =~ /rubyw/i)
|
732
774
|
|
733
775
|
$nobm = false
|
734
776
|
|
@@ -745,7 +787,7 @@ def bm(label="")
|
|
745
787
|
end
|
746
788
|
end
|
747
789
|
|
748
|
-
label = label.
|
790
|
+
label = label.inspect #unless label.kind_of?(String)
|
749
791
|
res = nil
|
750
792
|
|
751
793
|
$bm_mutex = ($bm_mutex or Mutex.new)
|
@@ -757,29 +799,41 @@ def bm(label="")
|
|
757
799
|
$bm = {}
|
758
800
|
|
759
801
|
at_exit do
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
802
|
+
l = $bm.keys.collect{|s| s.length}.max
|
803
|
+
#format1 = "%10s %10s %10s %10s %10s %10s %s"
|
804
|
+
#format2 = "%10.6f %10.6f %10.6f %10.6f %10.6f %10d %s"
|
805
|
+
#$stderr.puts format1 % ["USERCPU", "SYSCPU", "CUSERCPU", "CSYSCPU", "ELAPSED", "COUNT", "LABEL"]
|
806
|
+
#$bm.sort{|a, b| [b[1], b[0]] <=> [a[1], a[0]]}.each do |k, v|
|
807
|
+
#$stderr.puts format2 % (v + [k])
|
808
|
+
#end
|
809
|
+
|
810
|
+
format1 = "%10s %10s %10s %s"
|
811
|
+
format2 = "%10.6f %10.6f %10d %s"
|
812
|
+
$bm.each do |k, v|
|
813
|
+
$bm[k] = [v[0]+v[1], v[4], v[5]]
|
814
|
+
end
|
815
|
+
$stderr.puts format1 % ["CPU", "ELAPSED", "COUNT", "LABEL"]
|
816
|
+
$bm.sort{|a, b| [b[1], b[0]] <=> [a[1], a[0]]}.each do |k, v|
|
817
|
+
$stderr.puts format2 % (v + [k])
|
766
818
|
end
|
767
819
|
end
|
768
820
|
end
|
769
821
|
|
770
822
|
$bm[label] = [0.0]*5 + [0] unless $bm.include?(label)
|
823
|
+
$bm[label][5] += 1
|
771
824
|
end
|
772
825
|
|
773
826
|
if block_given?
|
774
827
|
bm = Benchmark.measure{res = yield}
|
775
828
|
bma = bm.to_a # [dummy label, user CPU time, system CPU time, childrens user CPU time, childrens system CPU time, elapsed real time]
|
776
829
|
|
830
|
+
$bm_last = bma
|
831
|
+
|
777
832
|
$bm_mutex.synchronize do
|
833
|
+
e = $bm[label]
|
778
834
|
0.upto(4) do |n|
|
779
|
-
|
835
|
+
e[n] += bma[n+1]
|
780
836
|
end
|
781
|
-
|
782
|
-
$bm[label][5] += 1
|
783
837
|
end
|
784
838
|
end
|
785
839
|
|
@@ -817,3 +871,19 @@ def lambda_cached(&block)
|
|
817
871
|
res
|
818
872
|
end
|
819
873
|
end
|
874
|
+
|
875
|
+
def ask(options, text=false)
|
876
|
+
i = 0
|
877
|
+
$stderr.puts ""
|
878
|
+
options.each do |s|
|
879
|
+
$stderr.puts " %d %s" % [i+=1, s]
|
880
|
+
end
|
881
|
+
$stderr.puts ""
|
882
|
+
$stderr.print "? "
|
883
|
+
res = $stdin.gets
|
884
|
+
unless res.nil?
|
885
|
+
res = res.strip
|
886
|
+
res = options[res.to_i-1] if text and not res.empty?
|
887
|
+
end
|
888
|
+
res
|
889
|
+
end
|