summaryrefslogtreecommitdiff
path: root/lib/net
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-07-08 07:00:23 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-07-08 07:00:23 +0000
commit2b67bb576af535744c303baf289386d910df49c8 (patch)
tree7f59575bb477555c913bf0d9c676b81afb17f581 /lib/net
parent7f326a3988c74073619689f51481093885f5c203 (diff)
aamine
* lib/net/http.rb: rename HTTP#request_by_name to send_request. * lib/net/protocol.rb (ProtoSocket#read): modify typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/http.rb74
-rw-r--r--lib/net/pop.rb2
-rw-r--r--lib/net/protocol.rb6
-rw-r--r--lib/net/smtp.rb2
4 files changed, 61 insertions, 23 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 3a5b0cb2da..f2b6635fd4 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1,6 +1,6 @@
=begin
-= net/http.rb version 1.2.2
+= net/http.rb version 1.2.3
Copyright (c) 1999-2001 Yukihiro Matsumoto
@@ -266,10 +266,7 @@ Yes, this is not thread-safe.
Net::HTTP.start( 'some.www.server', 80 ) {|http|
response = http.head( '/index.html' )
}
- response['content-length'] #-> '2554'
- response['content-type'] #-> 'text/html'
- response['Content-Type'] #-> 'text/html'
- response['CoNtEnT-tYpe'] #-> 'text/html'
+ p response['content-type']
: post( path, data, header = nil, dest = '' )
: post( path, data, header = nil ) {|str| .... }
@@ -286,32 +283,74 @@ Yes, this is not thread-safe.
by "anException.response".
# version 1.1
- response, body = http.post( '/index.html', 'querytype=subject&target=ruby' )
+ response, body = http.post( '/cgi-bin/search.rb', 'querytype=subject&target=ruby' )
# version 1.2
- response = http.post( '/index.html', 'querytype=subject&target=ruby' )
+ response = http.post( '/cgi-bin/search.rb', 'querytype=subject&target=ruby' )
# compatible for both version
- response , = http.post( '/index.html', 'querytype=subject&target=ruby' )
+ response , = http.post( '/cgi-bin/search.rb', 'querytype=subject&target=ruby' )
# using block
File.open( 'save.html', 'w' ) {|f|
- http.post( '/index.html', 'querytype=subject&target=ruby' ) do |str|
+ http.post( '/cgi-bin/search.rb', 'querytype=subject&target=ruby' ) do |str|
f.write str
end
}
# same effect
File.open( 'save.html', 'w' ) {|f|
- http.post '/index.html', 'querytype=subject&target=ruby', nil, f
+ http.post '/cgi-bin/search.rb', 'querytype=subject&target=ruby', nil, f
+ }
+
+: get2( path, header = nil )
+: get2( path, header = nil ) {|response| .... }
+ gets entity from PATH. This method returns a HTTPResponse object.
+
+ When called with block, keep connection while block is executed
+ and gives a HTTPResponse object to the block.
+
+ This method never raise any ProtocolErrors.
+
+ # example
+ response = http.get2( '/index.html' )
+ p response['content-type']
+ puts response.body # body is already read
+
+ # using block
+ http.get2( '/index.html' ) {|response|
+ p response['content-type']
+ response.read_body do |str| # read body now
+ print str
+ end
+ }
+
+: post2( path, header = nil )
+: post2( path, header = nil ) {|response| .... }
+ posts data to PATH. This method returns a HTTPResponse object.
+
+ When called with block, gives a HTTPResponse object to the block
+ before reading entity body, with keeping connection.
+
+ # example
+ response = http.post2( '/cgi-bin/nice.rb', 'datadatadata...' )
+ p response.status
+ puts response.body # body is already read
+
+ # using block
+ http.post2( '/cgi-bin/nice.rb', 'datadatadata...' ) {|response|
+ p response.status
+ p response['content-type']
+ response.read_body do |str| # read body now
+ print str
+ end
}
: request( request [, data] )
: request( request [, data] ) {|response| .... }
- sends a HTTPRequest object REQUEST to (remote) http server.
- This method also writes string from DATA string if REQUEST is
- a post/put request. Giving DATA for get/head request causes
- ArgumentError.
+ sends a HTTPRequest object REQUEST to the (remote) http server.
+ This method also writes DATA string if REQUEST is a post/put request.
+ Giving DATA for get/head request causes ArgumentError.
- If called with block, gives a HTTPResponse object to the block
- with connecting server.
+ If called with block, passes a HTTPResponse object to the block
+ before reading entity body.
== class Net::HTTP::Get, Head, Post
@@ -397,7 +436,6 @@ All arguments named KEY is case-insensitive.
response body. If #read_body has been called, this method returns
arg of #read_body DEST. Else gets body as String and returns it.
-
=end
require 'net/protocol'
@@ -610,7 +648,7 @@ module Net
req.response
end
- def request_by_name( name, path, body = nil, header = nil )
+ def send_request( name, path, body = nil, header = nil )
r = ::Net::NetPrivate::HTTPGenericRequest.new(
name, (body ? true : false), true,
path, header )
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index 793532fffc..c05d42ad1e 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -1,6 +1,6 @@
=begin
-= net/pop.rb version 1.2.2
+= net/pop.rb version 1.2.3
Copyright (c) 1999-2001 Yukihiro Matsumoto
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index aba2256b6e..edc0f24b6e 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -1,6 +1,6 @@
=begin
-= net/protocol.rb version 1.2.2
+= net/protocol.rb version 1.2.3
Copyright (c) 1999-2001 Yukihiro Matsumoto
@@ -32,7 +32,7 @@ module Net
class Protocol
- Version = '1.2.2'
+ Version = '1.2.3'
class << self
@@ -532,7 +532,7 @@ module Net
CRLF = "\r\n"
- def read( len, dest = '', ignerr = false )
+ def read( len, dest = '', igneof = false )
D_off "reading #{len} bytes..."
rsize = 0
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 186ffa291a..b7dfbf822b 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -1,6 +1,6 @@
=begin
-= net/smtp.rb version 1.2.2
+= net/smtp.rb version 1.2.3
Copyright (c) 1999-2001 Yukihiro Matsumoto