[#4076] Re: call/cc — shugo@... (Shugo Maeda)

51 messages 1999/01/08
[#4077] Re: [ruby-list:11512] Re: call/cc — maeda@... 1999/01/08

前田@リコーです。

[#4078] Re: call/cc — shugo@... (Shugo Maeda) 1999/01/08

[#4079] Re: call/cc — kjana@... (YANAGAWA Kazuhisa) 1999/01/08

In message <m0zyZO8-0003EbC@crunkey.chocolate.or.jp>

[#4098] Re: call/cc — shugo@... (Shugo Maeda) 1999/01/11

[#4105] Re: call/cc — EGUCHI Osamu <eguchi@...> 1999/01/12

えぐち@エスアンドイー です。

[#4144] Re: call/cc — shugo@... (Shugo Maeda) 1999/01/13

[#4090] finalizers — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

19 messages 1999/01/11

[#4095] Ruby on CYGWIN — TAKAHASHI Masayoshi <maki@...>

高橋です。久しぶりに書きます。

26 messages 1999/01/11
[#4111] Re: Ruby on CYGWIN — WATANABE Hirofumi <watanabe@...> 1999/01/12

わたなべです.

[#4115] Re: Ruby on CYGWIN — TAKAHASHI Masayoshi <maki@...> 1999/01/12

高橋です。Rubyのリンク集から見つけたのですが、sgmailって

[#4118] sgmail (Re: Ruby on CYGWIN) — Takahiro Maebashi <maebashi@...> 1999/01/12

前橋です。

[#4123] Tk? Gtk? (Re: sgmail) — TAKAHASHI Masayoshi <maki@...> 1999/01/13

高橋です。

[#4203] Compile via WATCOM C — ARIMA Yasuhiro <fit0298@...>

有馬です。

20 messages 1999/01/18
[#4204] Re: Compile via WATCOM C — KIMURA Koichi <kimura@...> 1999/01/18

[#4248] patch for ruby-mswin32 — Koji Oda <oda@...1.qnes.nec.co.jp>

小田@QNES です。

27 messages 1999/01/19
[#4254] Re: patch for ruby-mswin32 — matz@... (Yukihiro Matsumoto) 1999/01/19

まつもと ゆきひろです

[#4256] Re: patch for ruby-mswin32 — WATANABE Hirofumi <watanabe@...> 1999/01/19

わたなべです.

[#4258] Re: patch for ruby-mswin32 — matz@... (Yukihiro Matsumoto) 1999/01/19

まつもと ゆきひろです

[#4290] signed/unsigned char — ARIMA Yasuhiro <fit0298@...>

有馬です。

17 messages 1999/01/20
[#4292] Re: signed/unsigned char — EGUCHI Osamu <eguchi@...> 1999/01/20

えぐち@エスアンドイー です。

[#4293] Re: signed/unsigned char — ARIMA Yasuhiro <fit0298@...> 1999/01/20

Regard to "[ruby-dev:4292] Re: signed/unsigned char"

[#4295] Re: signed/unsigned char — EGUCHI Osamu <eguchi@...> 1999/01/20

えぐち@エスアンドイー です。

[#4327] pack("F") for bigendian float — gotoken@... (GOTO Kentaro)

ごとけんです。

25 messages 1999/01/22
[#4330] Re: pack("F") for bigendian float — gotoken@... (GOTO Kentaro) 1999/01/23

ごとけんです

[#4331] Re: pack("F") for bigendian float — gotoken@... (GOTO Kentaro) 1999/01/23

ごとけんです

[#4336] Re: pack("F") for bigendian float — matz@... (Yukihiro Matsumoto) 1999/01/24

まつもと ゆきひろです

[#4337] Re: pack("F") for bigendian float — gotoken@... (GOTO Kentaro) 1999/01/24

ごとけんです

[#4338] Re: pack("F") for bigendian float — Yamashita Junji (山下 純司) <ys_jyunji@...> 1999/01/24

山下 純司です。

[#4341] cascades on ruby — Kazunori NISHI <kazunori@...>

西@九大です。

51 messages 1999/01/25
[#4342] Re: cascades on ruby — Kazuhiro HIWADA <hiwada@...> 1999/01/25

ひわだです。

[#4343] Re: cascades on ruby — Kazunori NISHI <kazunori@...> 1999/01/25

西@九大です。

[#4344] Re: cascades on ruby — matz@... (Yukihiro Matsumoto) 1999/01/25

まつもと ゆきひろです

[#4386] Re: cascades on ruby — keiju@... (石塚圭樹 ) 1999/01/26

けいじゅ@日本ラショナルソフトウェアです.

[#4389] Re: cascades on ruby — matz@... (Yukihiro Matsumoto) 1999/01/26

まつもと ゆきひろです

[#4394] Re: cascades on ruby — keiju@... (石塚圭樹 ) 1999/01/26

けいじゅ@日本ラショナルソフトウェアです.

[#4396] keyword argument (Re: Re: cascades on ruby) — matz@... (Yukihiro Matsumoto) 1999/01/26

[#4399] Re: keyword argument (Re: Re: cascades on ruby) — keiju@... (石塚圭樹 ) 1999/01/26

けいじゅ@日本ラショナルソフトウェアです.

[#4400] Re: keyword argument (Re: Re: cascades on ruby) — matz@... (Yukihiro Matsumoto) 1999/01/26

まつもと ゆきひろです

[#4401] Re: keyword argument (Re: Re: cascades on ruby) — keiju@... (石塚圭樹 ) 1999/01/26

けいじゅ@日本ラショナルソフトウェアです.

[#4404] Re: keyword argument (Re: Re: cascades on ruby) — matz@... (Yukihiro Matsumoto) 1999/01/26

まつもと ゆきひろです

[#4410] Re: keyword argument (Re: Re: cascades on ruby) — keiju@... (石塚圭樹 ) 1999/01/26

けいじゅ@日本ラショナルソフトウェアです.

[#4412] Re: keyword argument (Re: Re: cascades on ruby) — matz@... (Yukihiro Matsumoto) 1999/01/26

まつもと ゆきひろです

[#4473] Re: keyword argument (Re: Re: cascades on ruby) — matz@... (Yukihiro Matsumoto) 1999/01/28

まつもと ゆきひろです

[#4495] Re: keyword argument (Re: Re: cascades on ruby) — shugo@... (Shugo Maeda) 1999/01/29

前田です。

[#4349] Re: [ruby-list:11707] Re: ruby 1.2.2 released — EGUCHI Osamu <eguchi@...>

えぐち@エスアンドイー です。

35 messages 1999/01/25
[#4353] Re: [ruby-list:11707] Re: ruby 1.2.2 released — EGUCHI Osamu <eguchi@...> 1999/01/25

えぐち@エスアンドイー です。

[#4357] --enable-shared/BSD (Re: ) — EGUCHI Osamu <eguchi@...> 1999/01/25

えぐち@エスアンドイー です。

[#4375] Re: --enable-shared/BSD (Re: ) — matz@... (Yukihiro Matsumoto) 1999/01/26

まつもと ゆきひろです

[#4387] Re: --enable-shared/BSD (Re: ) — EGUCHI Osamu <eguchi@...> 1999/01/26

えぐち@エスアンドイー です。

[#4391] Re: --enable-shared/BSD (Re: ) — matz@... (Yukihiro Matsumoto) 1999/01/26

まつもと ゆきひろです

[#4406] Re: --enable-shared/BSD (Re: ) — EGUCHI Osamu <eguchi@...> 1999/01/26

えぐち@エスアンドイー です。

[#4419] Re: module Precision — Inaba Hiroto <inaba@...>

21 messages 1999/01/26
[#4438] Re: module Precision — gotoken@... (GOTO Kentaro) 1999/01/27

ごとけんです

[#4451] Re: module Precision — Inaba Hiroto <inaba@...> 1999/01/27

From: gotoken@math.sci.hokudai.ac.jp (GOTO Kentaro)

[#4453] new class for float of C (Re: module Precision) — gotoken@... (GOTO Kentaro) 1999/01/27

ごとけんです

[#4457] Re: new class for float of C (Re: module Precision) — matz@... (Yukihiro Matsumoto) 1999/01/28

まつもと ゆきひろです

[#4460] Re: new class for float of C (Re: module Precision) — gotoken@... (GOTO Kentaro) 1999/01/28

ごとけんです

[#4461] Re: new class for float of C (Re: module Precision) — matz@... (Yukihiro Matsumoto) 1999/01/28

まつもと ゆきひろです

[#4462] Re: new class for float of C (Re: module Precision) — gotoken@... (GOTO Kentaro) 1999/01/28

ごとけんです

[#4420] ruby 1.3.1-990126 — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

17 messages 1999/01/26

[#4452] permit to put a comma — Koji Arai <JCA02266@...>

新井です。

18 messages 1999/01/27
[#4484] Re: permit to put a comma — matz@... (Yukihiro Matsumoto) 1999/01/29

まつもと ゆきひろです

[#4518] Inf.0 — gotoken@... (GOTO Kentaro)

ごとけんです

17 messages 1999/01/30

[ruby-dev:4521] Re: cookie on cgi-lib.rb

From: Wakou Aoyama <wakou@...>
Date: 1999-01-31 01:05:52 UTC
List: ruby-dev #4521
青山です。

cookie の生成と header の生成は分離した方が良さそうなので、CGI.pm を参
考に整理し、足りなかったオプションにも対応してみました。

# foo.cookie['name']  <== cookie value of 'name'
# foo.cookie.keys     <== all cookie names
# and foo.cookie has Hash class methods
#
# make raw cookie string
# cookie1 = CGI.cookie({'name'    => 'name',
#                       'value'   => 'value',
#                       'path'    => 'path',   # optional
#                       'domain'  => 'domain', # optional
#                       'expires' => Time.now, # optional
#                       'secure'  => true      # optional
#                      })
#
# print CGI.header("Content-Type: text/html", cookie1, cookie2)
#
# print CGI.header("HTTP/1.0 200 OK", "Content-Type: text/html")
# print CGI.header # == print CGI.header("Content-Type: text/html")

CGI.header は HTTP.header の方が良さそうですけれどね。

以下は汎用ライブラリではなく個別対応の方が良いように思われますが、いか
がでしょう。

> +  def set_title(title)
> +    @title = title
> +  end

> +  def set_body(body)
> +    @body = body
> +  end

> +  def flush
> +    CGI.message(@body, @title, @header)
> +  end

> +  def clear_cookie(name)
> +    set_cookie(name, "xx", "Thu, 1-Jan-1980 00:00:00 GMT")
> +  end


--- cgi-lib.rb.org	Sun Jan 31 10:07:17 1999
+++ cgi-lib.rb	Sun Jan 31 09:51:32 1999
@@ -7,6 +7,24 @@
 # foo['field']   <== value of 'field'
 # foo.keys       <== array of fields
 # and foo has Hash class methods
+#
+# foo.cookie['name']  <== cookie value of 'name'
+# foo.cookie.keys     <== all cookie names
+# and foo.cookie has Hash class methods
+#
+# make raw cookie string
+# cookie1 = CGI.cookie({'name'    => 'name',
+#                       'value'   => 'value',
+#                       'path'    => 'path',   # optional
+#                       'domain'  => 'domain', # optional
+#                       'expires' => Time.now, # optional
+#                       'secure'  => true      # optional
+#                      })
+#
+# print CGI.header("Content-Type: text/html", cookie1, cookie2)
+#
+# print CGI.header("HTTP/1.0 200 OK", "Content-Type: text/html")
+# print CGI.header # == print CGI.header("Content-Type: text/html")
 
 # if running on Windows(IIS or PWS) then change cwd.
 if ENV['SERVER_SOFTWARE'] =~ /^Microsoft-/ then
@@ -17,7 +35,12 @@
 
 class CGI < SimpleDelegator
 
+  CR  = "\015"
+  LF  = "\012"
+  EOL = CR + LF
+
   attr("inputs")
+  attr("cookie")
 
   # original is CGI.pm
   def read_from_cmdline
@@ -40,7 +63,7 @@
 
   # unescape url encoded
   def unescape(str)
-    str.gsub! /\+/, ' '
+    str.gsub!(/\+/, ' ')
     str.gsub!(/%([0-9a-fA-F]{2})/){ [$1.hex].pack("c") }
     str
   end
@@ -70,10 +93,38 @@
     end
 
     super(@inputs)
+
+    if ENV.has_key?('HTTP_COOKIE')
+      @cookie = {}
+      ENV['HTTP_COOKIE'].split("; ").each do |x|
+	key, val = x.split(/=/,2).collect{|x|unescape(x)}
+	if @cookie.include?(key)
+	  @cookie[key] += "\0" + (val or "")
+	else
+	  @cookie[key] = (val or "")
+	end
+      end
+    end
+  end
+
+  def CGI.header(*options)
+    options.push("Content-Type: text/html") if options.empty?
+    if options.find{|item| /^Expires: |^Set-Cookie: /i === item}
+      options.push("Date: " + Time.now.gmtime.strftime("%a, %d %b %Y %X %Z"))
+    end
+    options.join(EOL) + EOL + EOL
+  end
+
+  def CGI.cookie(options)
+    "Set-Cookie: " + options['name'] + '=' + escape(options['value']) +
+    (options['domain']  ? '; domain='  + options['domain'] : '') +
+    (options['path']    ? '; path='    + options['path']   : '') +
+    (options['expires'] ? '; expires=' + options['expires'].strftime("%a, %d %b %Y %X %Z") : '') +
+    (options['secure']  ? '; secure' : '')
   end
 
-  def CGI.message(msg, title = "")
-    print "Content-type: text/html\n\n"
+  def CGI.message(msg, title = "", header = ["Content-Type: text/html"])
+    print CGI.header(*header)
     print "<html><head><title>"
     print title
     print "</title></head><body>\n"


- 
青山 和光 Wakou Aoyama <wakou@fsinet.or.jp>

In This Thread