#!/usr/local/bin/ruby
#encoding:utf-8
print "Content-type: text/html\n\n"
#
# u_01http.rb http関連
#

### code表示 ,rbファイル名
pgmei=File.basename($0)
code=%Q[<br><a href="dispcode.rb?fmei=#{pgmei}" target="_blank">code</a>]
$pgmei=pgmei;load'cntsub.rb'   #cnt,cnt_ip

### htmlテンプレ %reshtml%展開内容
wt=%Q[<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>#{pgmei}</title>
</head>
<body>
<h1>httpテスト</h1>
<h2>#{pgmei}  (http ヘッダ関連)</h2>
<br>
<hr>
%reshtml%
<br>
#{code}
</body>
</html>
]



### 表示
require"net/http"
#http=Net::HTTP.new('yahoo.co.jp')
http=Net::HTTP.new('open2ch.net')
response=http.head('/menu')
w=""
response.each do|name,value|
   w+=name+":"+value+"<br>\n"
end

print wt.sub!("%reshtml%",w)