summaryrefslogtreecommitdiff
path: root/lib/net
diff options
context:
space:
mode:
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/http.rb7
-rw-r--r--lib/net/protocol.rb5
-rw-r--r--lib/net/smtp.rb13
3 files changed, 17 insertions, 8 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 473cf5d8a3..bbe98274f4 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -504,7 +504,10 @@ module Net
end
def self.get_print( addr, path, port = nil )
- print get( addr, path, port )
+ new( addr, port || HTTP.port ).start {|http|
+ http.get path, nil, $stdout
+ }
+ nil
end
@@ -733,7 +736,7 @@ module Net
end
def basic_auth( acc, pass )
- @header['authorization'] = ["#{acc}:#{pass}"].pack('m').gsub(/\s+/, '')
+ @header['authorization'] = 'Basic ' + ["#{acc}:#{pass}"].pack('m').strip
end
end
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 7018158315..a440ef0817 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -363,7 +363,10 @@ module Net
@sock.__send__ @mid, str
end
- alias << write
+ def <<( str )
+ @sock.__send__ @mid, str
+ self
+ end
end
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 2e8377cddd..3b1d100fb3 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -153,12 +153,15 @@ module Net
end
end
- if user and secret then
+ if user or secret then
+ (user and secret) or
+ raise ArgumentError, "both of account and password are required"
+
mid = 'auth_' + (authtype || 'cram_md5').to_s
- unless @command.respond_to? mid then
- raise ArgumentError, "wrong auth type #{authtype.to_s}"
- end
- @command.send mid, user, secret
+ @command.respond_to? mid or
+ raise ArgumentError, "wrong auth type #{authtype.to_s}"
+
+ @command.__send__ mid, user, secret
end
end