зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
7f326a3988
Коммит
2b67bb576a
|
@ -1,3 +1,9 @@
|
|||
Sun Jul 8 16:04:35 2001 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* lib/net/http.rb: rename HTTP#request_by_name to send_request.
|
||||
|
||||
* lib/net/protocol.rb (ProtoSocket#read): modify typo.
|
||||
|
||||
Fri Jul 6 02:15:06 2001 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* lib/tempfile.rb: a tempfile must be created with mode 0600.
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче