[#10793] 今度こそ (patch of the ruby-1.4.6 for NT4.0&VC4.0 on DEC Alpha.) — kou@...1609.sip.eee.yamaguchi-u.ac.jp (Koichi Okada)
岡田です。
10 messages
2000/09/01
[#10815] Re: 今度こそ (patch of the ruby-1.4.6 for NT4.0&VC4.0on DEC Alpha.)
— nobu.nakada@...
2000/09/03
なかだです。
[#10816] Re: 今度こそ (patchof the ruby-1.4.6 for NT4.0&VC4.0on DEC Alpha.)
— kou@...1609.sip.eee.yamaguchi-u.ac.jp (Koichi Okada)
2000/09/04
岡田です。
[#10820] Re: 今度こそ (patchof the ruby-1.4.6 for NT4.0&VC4.0on DEC Alpha.)
— "Nobuyoshi.Nakada" <nobu.nakada@...>
2000/09/04
なかだ@ゴミです。
[#10866] Class Variable (sono 2) — Shin-ichiro HARA <sinara@...>
原です。
5 messages
2000/09/08
[#10882] setenv,unsetenv — Takaaki Tateishi <ttate@...>
立石です.
6 messages
2000/09/11
[#10894] Forward: [ruby-ext:01274] Re: 多重代入での to_a (Re: Ruby/Python doesn't work with Ruby 1.6) — matz@... (Yukihiro Matsumoto)
まつもと ゆきひろです
3 messages
2000/09/11
[#10897] Re: [CVS 266] "matz: 1.6.0 final (hopufully)" — WATANABE Hirofumi <Hirofumi.Watanabe@...>
わたなべです.
6 messages
2000/09/12
[#10903] Class Variable と継承 — Kazuhiro NISHIYAMA <zn@...>
メソッドや定数は子クラスの方が常に優先されるみたいですが
8 messages
2000/09/12
[#10914] Re: Class Variable と継承
— Yasushi Shoji <yashi@...>
2000/09/13
At Wed, 13 Sep 2000 02:57:29 +0900,
[#10920] SIGINT on windows — "Nobuyoshi.Nakada" <nobu.nakada@...>
なかだです。
17 messages
2000/09/14
[#11077] Re: SIGINT on windows
— matz@... (Yukihiro Matsumoto)
2000/09/27
まつもと ゆきひろです
[#11080] Re: SIGINT on windows
— Katsuyuki Komatsu <komatsu@...>
2000/09/27
小松です.
[#11081] Re: SIGINT on windows
— matz@... (Yukihiro Matsumoto)
2000/09/27
まつもと ゆきひろです
[#11089] Re: SIGINT on windows
— nobu.nakada@...
2000/09/27
なかだです。
[#11094] Re: SIGINT on windows
— nobu.nakada@...
2000/09/28
なかだです。
[#10921] proper tail recursion — Shugo Maeda <shugo@...>
前田です。
5 messages
2000/09/14
[#10943] Passing []/String as argument — Jun Adachi <adachi@...>
安達@沖データと申します。
2 messages
2000/09/18
[#10944] dummy DLL on Windows — "Nobuyoshi.Nakada" <nobu.nakada@...>
なかだです。
19 messages
2000/09/18
[#10955] Re: dummy DLL on Windows
— WATANABE Hirofumi <eban@...>
2000/09/19
わたなべです.
[#10963] Re: dummy DLL on Windows
— "Nobuyoshi.Nakada" <nobu.nakada@...>
2000/09/19
なかだです。
[#10964] Re: dummy DLL on Windows
— WATANABE Hirofumi <eban@...>
2000/09/19
わたなべです.
[#10967] Re: dummy DLL on Windows
— WATANABE Hirofumi <eban@...>
2000/09/19
わたなべです.
[#10970] Re: dummy DLL on Windows
— "Nobuyoshi.Nakada" <nobu.nakada@...>
2000/09/19
なかだです。
[#10971] Re: dummy DLL on Windows
— WATANABE Hirofumi <eban@...>
2000/09/19
わたなべです.
[#10975] Re: dummy DLL on Windows
— "Nobuyoshi.Nakada" <nobu.nakada@...>
2000/09/19
なかだです。
[#10976] Re: dummy DLL on Windows
— WATANABE Hirofumi <eban@...>
2000/09/19
わたなべです.
[#10977] Re: dummy DLL on Windows
— matz@... (Yukihiro Matsumoto)
2000/09/19
まつもと ゆきひろです
[#10979] Re: dummy DLL on Windows
— "Nobuyoshi.Nakada" <nobu.nakada@...>
2000/09/20
なかだです。
[#10946] require "marshal" failure — Katsuyuki Komatsu <komatsu@...>
小松です.
9 messages
2000/09/18
[#10949] Re: require "marshal" failure
— matz@... (Yukihiro Matsumoto)
2000/09/18
まつもと ゆきひろです
[#10953] Re: require "marshal" failure
— WATANABE Hirofumi <eban@...>
2000/09/19
わたなべです.
[#10948] File::Constants — Yasushi Shoji <yashi@...>
Wed Oct 22 12:52:30 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
5 messages
2000/09/18
[#10978] [PATCH] require in require — "Nobuyoshi.Nakada" <nobu.nakada@...>
なかだです。
15 messages
2000/09/20
[#10981] Re: [PATCH] require in require
— matz@... (Yukihiro Matsumoto)
2000/09/20
まつもと ゆきひろです
[#10982] ruby1.6.0 on win32c
— Akira Muraki <a-muraki@...>
2000/09/20
村木@日立ITです。
[#10993] Re: ruby1.6.0 on win32c
— WATANABE Hirofumi <eban@...>
2000/09/21
わたなべです.
[#10985] httphead.rb proxy version problem — Katsuyuki Komatsu <komatsu@...>
小松です.
16 messages
2000/09/20
[#10989] Re: httphead.rb proxy version problem
— Minero Aoki <aamine@...>
2000/09/20
あおきです。
[#10992] Re: httphead.rb proxy version problem
— Katsuyuki Komatsu <komatsu@...>
2000/09/21
小松です。
[#10996] Re: httphead.rb proxy version problem
— matz@... (Yukihiro Matsumoto)
2000/09/21
まつもと ゆきひろです
[#10997] Re: httphead.rb proxy version problem
— matz@... (Yukihiro Matsumoto)
2000/09/21
まつもと ゆきひろです
[#11006] lstat — WATANABE Hirofumi <eban@...>
わたなべです.
14 messages
2000/09/21
[#11007] Re: lstat
— matz@... (Yukihiro Matsumoto)
2000/09/21
まつもと ゆきひろです
[#11008] Re: lstat
— matz@... (Yukihiro Matsumoto)
2000/09/21
まつもと ゆきひろです
[#11028] regex.c warning of alpha — Katsuyuki Komatsu <komatsu@...>
小松です。
7 messages
2000/09/22
[#11037] RUBYLIB_PRIFIX at emx/gcc — kenn@...
長沢です。
7 messages
2000/09/22
[#11052] ruby-1.6.1-20000921-i386-cygwin and Thread — Shin-ichiro HARA <sinara@...>
原です。
12 messages
2000/09/24
[#11056] Re: ruby-1.6.1-20000921-i386-cygwin and Thread
— WATANABE Hirofumi <eban@...>
2000/09/24
わたなべです.
[#11057] Re: ruby-1.6.1-20000921-i386-cygwin and Thread
— Shin-ichiro Hara <sinara@...>
2000/09/25
原です。
[#11058] Re: ruby-1.6.1-20000921-i386-cygwin and Thread
— ARIMA Yasuhiro <fit0298@...>
2000/09/25
有馬です。
[#11066] [PATCH] gcc extension in regex.c — "Nobuyoshi.Nakada" <nobu.nakada@...>
なかだです。
6 messages
2000/09/26
[#11068] Re: [PATCH] gcc extension in regex.c
— "Nobuyoshi.Nakada" <nobu.nakada@...>
2000/09/26
なかだです。
[#11074] 定数のネスト — Kazuhiro NISHIYAMA <zn@...>
http://www2.osk.3web.ne.jp/~kgt/Ruby.html#000925_2
8 messages
2000/09/26
[ruby-dev:10989] Re: httphead.rb proxy version problem
From:
Minero Aoki <aamine@...>
Date:
2000-09-20 21:01:27 UTC
List:
ruby-dev #10989
あおきです。
In mail "[ruby-dev:10985] httphead.rb proxy version problem"
Katsuyuki Komatsu <komatsu@sarion.co.jp> wrote:
> 小松です.
>
> テストセットに使っている,[ruby-list:22001]のproxy対応の
> httphead.rbですが,Ruby 1.6.0でハングするようになってしまいました.
> netとrubyのどちらの問題でしょうか?
再現しません…。
でももしかしてこのパッチで直ったりしますか?
(関係ないだろうなあ。)
# あああ、talk でも指摘されてるー
-------------------------------------------------------------------
あおきみねろう
Index: net/http.rb
diff -u net/http.rb:1.10.2.30 net/http.rb:1.10.2.32
--- net/http.rb:1.10.2.30 Sun Aug 27 15:56:49 2000
+++ net/http.rb Thu Sep 21 05:40:24 2000
@@ -37,7 +37,7 @@
: start {|http| .... }
creates a new Net::HTTP object and starts HTTP session.
- When this method is called as iterator, gives HTTP object to block
+ When this method is called with block, gives HTTP object to block
and close HTTP session after block call finished.
: get( path, header = nil, dest = '' )
@@ -50,22 +50,21 @@
# example
response, body = http.get( '/index.html' )
- If called as iterator, give a part String of entity body.
+ If called with block, give a part String of entity body.
Note:
If status is not 2xx(success), ProtocolError exception is
- raised. At that time, you can get Response object from
+ raised. At that time, you can get HTTPResponse object from
execption object. (same in head/post)
# example
begin
- response, body = http.get(...)
+ response, body = http.get( '/index.html' )
rescue Net::ProtoRetriableError
response = $!.data
...
end
-
: head( path, header = nil )
get only header from "path" on connecting host.
"header" is a Hash like { 'Accept' => '*/*', ... }.
@@ -85,46 +84,76 @@
"header" must be a Hash like { 'Accept' => '*/*', ... }.
This method returns Net::HTTPResponse object and "dest".
- If called as iterator, gives a part String of entity body.
+ If called with block, gives a part String of entity body.
-: get2( path, header = nil ) {|adapter| .... }
+: get2( path, header = nil )
+: get2( path, header = nil ) {|recv| .... }
send GET request for "path".
"header" must be a Hash like { 'Accept' => '*/*', ... }.
- This method gives HTTPReadAdapter object to block.
+ If this method is called with block, one gives
+ a HTTPResponseReceiver object to block.
- ex.
-
- http.get2( '/index.html' ) do |f|
- # f is a HTTPReadAdapter object
- f.header
- f.body
+ # example
+ http.get2( '/index.html' ) do |recv|
+ # "recv" is a HTTPResponseReceiver object
+ recv.header
+ recv.body
+ end
+
+ # another way
+ response = http.get2( '/index.html' )
+ response['content-type']
+ response.body
+
+ # this is wrong
+ http.get2( '/index.html' ) do |recv|
+ print recv.header.body # body is not read yet!!!
+ end
+
+ # but this is ok
+ http.get2( '/index.html' ) do |recv|
+ recv.body # read body and set recv.header.body
+ print recv.header.body # ref
end
: head2( path, header = nil )
+: head2( path, header = nil ) {|recv| .... }
send HEAD request for "path".
"header" must be a Hash like { 'Accept' => '*/*', ... }.
The difference between "head" method is that
"head2" does not raise exceptions.
- ex.
-
- http.head2( '/index.html' ) do |f|
- f.header
+ If this method is called with block, one gives
+ a HTTPResponseReceiver object to block.
+
+ # example
+ response = http.head2( '/index.html' )
+
+ # another way
+ http.head2( '/index.html' ) do |recv|
+ recv.response
end
-: post2( path, data, header = nil ) {|adapter| .... }
+: post2( path, data, header = nil )
+: post2( path, data, header = nil ) {|recv| .... }
post "data"(must be String now) to "path".
"header" must be a Hash like { 'Accept' => '*/*', ... }.
- This method gives HTTPReadAdapter object to block.
+ If this method is called with block, one gives
+ a HTTPResponseReceiver object to block.
- ex.
-
- http.post2( '/index.html', 'data data data...' ) do |adapter|
- adapter.header
- adapter.body
+ # example
+ http.post2( '/anycgi.rb', 'data data data...' ) do |recv|
+ # "recv" is a HTTPResponseReceiver object
+ recv.header
+ recv.body
end
+ # another way
+ response = http.post2( '/anycgi.rb', 'important data' )
+ response['content-type']
+ response.body
+
= class HTTPResponse
HTTP response object.
@@ -155,8 +184,9 @@
: message
HTTP result message. For example, 'Not Found'
+
-= class HTTPReadAdapter
+= class HTTPResponseReceiver
== Methods
@@ -169,8 +199,8 @@
entity body. A body is written to "dest" using "<<" method.
: body {|str| ... }
- get entity body by using iterator.
- If this method is called twice, block is not called and
+ gets entity body with block.
+ If this method is called twice, block is not executed and
returns first "dest".
@@ -287,8 +317,9 @@
end
def get2( path, u_header = nil, &block )
- connecting( u_header, block ) {|uh|
+ connecting( u_header ) {|uh|
@command.get edit_path(path), uh
+ receive true, block
}
end
@@ -299,10 +330,10 @@
resp
end
- def head2( path, u_header = nil )
- connecting( u_header, nil ) {|uh|
+ def head2( path, u_header = nil, &block )
+ connecting( u_header ) {|uh|
@command.head edit_path(path), uh
- @command.get_response_no_body
+ receive false, block
}
end
@@ -315,8 +346,9 @@
end
def post2( path, data, u_header = nil, &block )
- connecting( u_header, block ) {|uh|
+ connecting( u_header ) {|uh|
@command.post edit_path(path), uh, data
+ receive true, block
}
end
@@ -329,8 +361,9 @@
end
def put2( path, src, u_header = nil, &block )
- connecting( u_header, block ) {|uh|
+ connecting( u_header ) {|uh|
@command.put path, uh, src
+ receive true, block
}
end
@@ -338,14 +371,7 @@
private
- # called when connecting
- def do_finish
- unless @socket.closed? then
- head2 '/', { 'Connection' => 'close' }
- end
- end
-
- def connecting( u_header, ublock )
+ def connecting( u_header )
u_header = procheader( u_header )
if not @socket then
u_header['Connection'] = 'close'
@@ -355,12 +381,7 @@
end
resp = yield( u_header )
- if ublock then
- adapter = HTTPReadAdapter.new( @command )
- ublock.call adapter
- resp = adapter.off
- end
-
+
unless keep_alive? u_header, resp then
@socket.close
end
@@ -400,22 +421,37 @@
end
end
+
+ def receive( body_exist, block )
+ recv = HTTPResponseReceiver.new( @command, body_exist )
+ block.call recv if block
+ recv.terminate
+ recv.header
+ end
+
+
+ # called when connecting
+ def do_finish
+ unless @socket.closed? then
+ head2 '/', { 'Connection' => 'close' }
+ end
+ end
+
def edit_path( path )
path
end
- class << self
- def Proxy( p_addr, p_port )
- klass = super
- klass.module_eval %-
- def edit_path( path )
- 'http://' + address +
- (@port == #{self.port} ? '' : ':' + @port.to_s) + path
- end
- -
- klass
- end
+ def HTTP.Proxy( p_addr, p_port = nil )
+ klass = super
+ klass.module_eval %-
+ def edit_path( path )
+ 'http://' + address +
+ (@port == HTTP.port ? '' : ":#{@port}") +
+ path
+ end
+ -
+ klass
end
end
@@ -525,10 +561,11 @@
HTTPVersionNotSupported = HTTPFatalErrorCode.mkchild
- class HTTPReadAdapter
+ class HTTPResponseReceiver
- def initialize( command )
+ def initialize( command, body_exist )
@command = command
+ @body_exist = body_exist
@header = @body = nil
end
@@ -538,7 +575,9 @@
def header
unless @header then
- @header = @command.get_response
+ stream_check
+ @header = @body_exist ? @command.get_response :
+ @command.get_response_no_body
end
@header
end
@@ -547,20 +586,31 @@
def body( dest = nil, &block )
dest, ret = HTTP.procdest( dest, block )
unless @body then
- @body = @command.get_body( response, dest )
+ stream_check
+ @body = @command.get_body( header, dest )
end
@body
end
alias entity body
- def off
- body
+ def terminate
+ header
+ body if @body_exist
@command = nil
- @header
end
+
+ private
+
+ def stream_check
+ unless @command then
+ raise IOError, 'receiver was used out of block'
+ end
+ end
end
+ HTTPReadAdapter = HTTPResponseReceiver
+
module NetPrivate
@@ -574,11 +624,8 @@
@http_version = HTTPVersion
@in_header = {}
- if sock.port == HTTP.port
- @in_header[ 'Host' ] = sock.addr
- else
- @in_header[ 'Host' ] = sock.addr + ':' + sock.port
- end
+ @in_header[ 'Host' ] = sock.addr +
+ ((sock.port == HTTP.port) ? '' : ":#{sock.port}")
@in_header[ 'Connection' ] = 'Keep-Alive'
@in_header[ 'Accept' ] = '*/*'