summaryrefslogtreecommitdiff
path: root/sample/drb/http0.rb
diff options
context:
space:
mode:
authorzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-20 13:41:02 +0000
committerzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-20 13:41:02 +0000
commitb4489ae953601cceb30e5dbdac5fe213ecad1b75 (patch)
tree0e8bea2d6e4a0cdfc900c835653a83a2637ff740 /sample/drb/http0.rb
parent368cecc1517ba2a09b0413eeaf5c3ba9981de4db (diff)
* sample/*: whitespace patch by Sergio Campama [Fixes GH-364]
https://github.com/ruby/ruby/pull/364 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/drb/http0.rb')
-rw-r--r--sample/drb/http0.rb60
1 files changed, 30 insertions, 30 deletions
diff --git a/sample/drb/http0.rb b/sample/drb/http0.rb
index d4c9f6b..e40d810 100644
--- a/sample/drb/http0.rb
+++ b/sample/drb/http0.rb
@@ -6,20 +6,20 @@ module DRb
module HTTP0
class StrStream
def initialize(str='')
- @buf = str
+ @buf = str
end
attr_reader :buf
def read(n)
- begin
- return @buf[0,n]
- ensure
- @buf[0,n] = ''
- end
+ begin
+ return @buf[0,n]
+ ensure
+ @buf[0,n] = ''
+ end
end
def write(s)
- @buf.concat s
+ @buf.concat s
end
end
@@ -29,47 +29,47 @@ module DRb
def self.open(uri, config)
unless /^http:/ =~ uri
- raise(DRbBadScheme, uri) unless uri =~ /^http:/
- raise(DRbBadURI, 'can\'t parse uri:' + 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']
+ @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)
+ 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)
+ @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
+ 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