[#6728] Ruby 1.3.3-990507 — matz <matz@...>

Ruby 1.3.3-990507 is out, check out:

34 messages 1999/05/07
[#6731] Re: Ruby 1.3.3-990507 — Katsuyuki Komatsu <komatsu@...> 1999/05/07

小松です。

[#6779] Re: private inner class (Re: Re: class def in class def) — Koji Oda <oda@...1.qnes.nec.co.jp>

小田@QNES です。

13 messages 1999/05/13

[#6789] Ruby 1.3.3-990513 — Yukihiro Matsumoto <matz@...>

Ruby 1.3.3-990513 is out, check out:

59 messages 1999/05/13
[#6811] Re: Ruby 1.3.3-990513 — Koji Oda <oda@...1.qnes.nec.co.jp> 1999/05/14

小田@QNES です。

[#6814] Re: Ruby 1.3.3-990513 — matz@... (Yukihiro Matsumoto) 1999/05/15

まつもと ゆきひろです

[#6821] Re: Ruby 1.3.3-990513 — Koji Oda <oda@...1.qnes.nec.co.jp> 1999/05/16

小田@QNES です。

[#6790] Re: Ruby 1.3.3-990513 — Katsuyuki Komatsu <komatsu@...> 1999/05/13

小松です。

[#6891] Ruby 1.3.3-990518 — Yukihiro Matsumoto <matz@...>

Ruby 1.3.3-990518 is out, check out:

19 messages 1999/05/18

[#6919] ext/socket/getaddrinfo.c tiny fix — Jun-ichiro itojun Hagino <itojun@...>

ext/socket/getaddrinfo.cに以下のpatchをおねがいします。

22 messages 1999/05/20
[#6921] Re: ext/socket/getaddrinfo.c tiny fix — Jun-ichiro itojun Hagino <itojun@...> 1999/05/20

[#7034] Ruby 1.3.4-990531 — Yukihiro Matsumoto <matz@...>

Ruby 1.3.4-990531 is out, check out:

25 messages 1999/05/31

[ruby-dev:7002] Re: http-access

From: TAKAHASHI Masayoshi <maki@...>
Date: 1999-05-27 03:32:39 UTC
List: ruby-dev #7002
高橋です。http-accessについて。

Takahiro Maebashi <maebashi@iij.ad.jp>さん:
> いやあ、その後は何も変化はありません。

そうでしたか。

> > # あれ、URLってhostとportの書式は決まってないんでしたっけ?
> 
> RFC1738 にあるみたいです。
> 
> //<user>:<password>@<host>:<port>/<url-path>

一応RFCこれってどのschemeで使えるか、というのは決まってないん
ですよね? RFC 2396にはなさそうでした。

> > 試しに自分でも書きかけているのですが(^^;、すでにあるのなら
> > それを使いたいです。
> そういうわけで書いて頂けると嬉しいです(^^;

わかりました。(^^;;

というわけで、とりあえず書いてみたurl-parse.rbの差分をつけておきます。
user, passwd, host, portというメソッドを加えてあります。

で、http-accessについてなのですが、使い方についての質問があります。

require 'http-access'
require 'url-parse'

$proxy= nil

k = "www.nowhere-net.or.jp"
url1 = "/~some/index.html"
url2 = "/~another/index.html"

h = HTTPAccess.new(k, HTTPAccess::HTTP_Port, $proxy)

h.request_head(url1)
h.get_header{|head|
  print head
}
h.request_head(url2)
h.get_header{|head|
  print head
}
h.close

といったようなことを書いても、どうも同じファイルを見に行ってしまっ
ている(Etag, Last-modified,などみんな同じ)ようなのですが、これはど
うしてなのでしょうか?  何か使い方がまずいのでしょうか。



*** url-parse.rb.org	Tue May 25 09:15:41 1999
--- url-parse.rb	Tue May 25 18:22:38 1999
***************
*** 1,10 ****
--- 1,14 ----
  # Parse URLs.
  class URL
    attr_reader :urlstr, :scheme, :netloc, :path, :params, :query, :fragment
+   attr_reader :user, :passwd, :host, :port
  
    Uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet', 'wais',
      'https', 'shttp', 'snews', 'prospero', '']
  
+   Uses_login = ['ftp','http','gopher','nntp','telnet','wais',
+     'prospero']
+ 
    def initialize(urlstr, scheme=nil)
      @urlstr = urlstr
      parse(urlstr, scheme)
***************
*** 15,20 ****
--- 19,25 ----
    def parse(url, scheme = nil, allow_fragments = true)
      @scheme = scheme
      @netloc = @params = @query = @fragment = nil
+     @host = @port = nil
  
      if url =~ /^([-+\.\w]+):/
        @scheme, url = $1, $' #'
***************
*** 29,34 ****
--- 34,46 ----
        @scheme = 'file'
      end
  
+     # parse netloc into userinfo and hostinfo
+     # for more detail, see RFC 2396 3.2.2 and Appendix A.
+     if /(([^:@]*)(:([^@]*))?@)?([^:]*)(:(\d*))?/ =~ @netloc  &&
+ 	Uses_login.include?(@scheme)
+       @user, @passwd, @host, @port = $2, $4, $5, $7
+     end
+ 
      if @scheme == 'http'
        i = url.rindex("#")
        if i
***************
*** 48,51 ****
--- 60,72 ----
      @path = '/' if @path == ''
    end
  
+ end
+ 
+ if $0 == __FILE__
+   u = URL.new('http://foo:var@www.hogehoge.jp:8080/hoge/fu;ni?ha#un')
+ 
+   ['urlstr', 'scheme', 'netloc', 'host', 'port', 'user',
+     'passwd', 'path', 'params', 'query', 'fragment'].each{|m|
+     print m,": ",eval("u." + m),"\n"
+   }
  end


In This Thread