[#44578] Ruby初心者が作りました — Kabu and Ruby管理人 <kabu_and_ruby@...>

http://www.geocities.jp/kabuandruby/index.html

26 messages 2008/02/06

[#44691] ”Rubyアプリケーションプログラミング”の伝言サーバの使い方 — "Yangkook Kim" <yangkookkim@...>

キムと申します。オーム社から出版されている書籍、"Rubyアプリケーションプログラミング"のP267~275に掲載されている伝言サーバー&クライアントの利用の仕方がわかりません。質問を要約すると次の2点です。1、サーバーが正常に起動されているかどうかわからない。2、書き込みクライアントで入力をサーバーに送信する方法がわからない。

8 messages 2008/02/24

[ruby-list:44667] Re: Net::HTTP について

From: Nobuyoshi Nakada <nobu@...>
Date: 2008-02-20 06:00:55 UTC
List: ruby-list #44667
なかだです。

At Wed, 20 Feb 2008 13:37:41 +0900,
大道 裕 wrote in [ruby-list:44665]:
> > 4. terminalから、の入力で、
> > $ curl http://example.com
> > に対しては弾かれ、
> > $ curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)" http://example.com
> > では成功する場合は、user-agent を偽装すれば良いということになります。(curlが使える場合)
> 
> curlでは、問題なく表示されます。

curlもデフォルトでUser-Agentを付けています。

  $ curl -A "" http://www.koeki-data.soumu.go.jp
  <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
  <html><head>
  <title>400 Bad Request</title>
  </head><body>
  <h1>Bad Request</h1>
  <p>Your browser sent a request that this server could not understand.<br />
  </p>
  <hr>
  <address>Microsoft-llS/6.0 Server at www.koeki-data.soumu.go.jp Port 80</address>
  </body></html>

  $ ruby -ruri -rnet/http -e 'Net::HTTP.start("www.koeki-data.soumu.go.jp"){|h|puts h.get("/", "User-Agent"=>"foobar").body[/.*\n\r$/m]}'
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  <HTML>
  <HEAD>
  <META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
  <META http-equiv="Content-Style-Type" content="text/css">
  <TITLE>公益法人データベース</TITLE>
  <SCRIPT language="JavaScript">
  <!--HPB_SCRIPT_ROV_50

-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread