diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
commit | d0233291bc8a5068e52c69c210e5979e5324b5bc (patch) | |
tree | 7d9459449c33792c63eeb7baa071e76352e0baab /trunk/sample/drb/http0.rb | |
parent | 0dc342de848a642ecce8db697b8fecd83a63e117 (diff) | |
parent | 72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff) |
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/sample/drb/http0.rb')
-rw-r--r-- | trunk/sample/drb/http0.rb | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/trunk/sample/drb/http0.rb b/trunk/sample/drb/http0.rb deleted file mode 100644 index 7649925282..0000000000 --- a/trunk/sample/drb/http0.rb +++ /dev/null @@ -1,77 +0,0 @@ -require 'drb/drb' -require 'net/http' -require 'uri' - -module DRb - module HTTP0 - class StrStream - def initialize(str='') - @buf = str - end - attr_reader :buf - - def read(n) - begin - return @buf[0,n] - ensure - @buf[0,n] = '' - end - end - - def write(s) - @buf.concat s - end - end - - def self.uri_option(uri, config) - return uri, nil - end - - def self.open(uri, config) - unless /^http:/ =~ uri - raise(DRbBadScheme, uri) unless uri =~ /^http:/ - raise(DRbBadURI, 'can\'t parse uri:' + uri) - end - ClientSide.new(uri, config) - end - - class ClientSide - def initialize(uri, config) - @uri = uri - @res = nil - @config = config - @msg = DRbMessage.new(config) - @proxy = ENV['HTTP_PROXY'] - end - - def close; end - def alive?; false; end - - def send_request(ref, msg_id, *arg, &b) - stream = StrStream.new - @msg.send_request(stream, ref, msg_id, *arg, &b) - @reply_stream = StrStream.new - post(@uri, stream.buf) - end - - def recv_reply - @msg.recv_reply(@reply_stream) - end - - def post(url, data) - it = URI.parse(url) - path = [(it.path=='' ? '/' : it.path), it.query].compact.join('?') - http = Net::HTTP.new(it.host, it.port) - sio = StrStream.new - http.post(path, data, {'Content-Type'=>'application/octetstream;'}) do |str| - sio.write(str) - if @config[:load_limit] < sio.buf.size - raise TypeError, 'too large packet' - end - end - @reply_stream = sio - end - end - end - DRbProtocol.add_protocol(HTTP0) -end |