種類
- インスタンスメソッド (143)
- ライブラリ (11)
- クラス (11)
ライブラリ
-
net
/ http (22) -
webrick
/ httpauth / basicauth (11) -
webrick
/ httpresponse (55) -
webrick
/ httpservlet / abstract (66)
クラス
キーワード
- BasicAuth (11)
- body (11)
- chunked= (11)
-
content
_ length (11) -
content
_ length= (11) -
do
_ DELETE (11) -
do
_ GET (11) -
do
_ HEAD (11) -
do
_ OPTIONS (11) -
do
_ POST (11) -
do
_ PUT (11) -
to
_ s (11) -
webrick
/ cgi (11)
検索結果
先頭5件
-
Net
:: HTTPGenericRequest # body=(body) (18112.0) -
サーバに送るリクエストのエンティティボディを文字列で設定します。
...。
@param body 設定するボディを文字列で与えます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Post.new(uri.request_uri)
req.body = "Test Post Data" # => "Test Post Data"
//}
@see Net::HTTPGenericRequest#body... -
WEBrick
:: HTTPResponse # body=(val) (18112.0) -
クライアントに返す内容(エンティティボディ)をセットします。
...適切にチャンク形式エンコーディングされます。
require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion => "1.1" } )
res.body = 'hoge'
print res.to_s
#=> 出力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sat, 27 Oct 2007 08:58:49 GMT... -
webrick
/ cgi (60.0) -
一般の CGI 環境で webrick ライブラリのサーブレットと同じように CGI スクリプトを書くための ライブラリです。サーバが WEBrick でなくても使うことが出来ます。
...brick/cgi'
class MyCGI < WEBrick::CGI
def do_GET(req, res)
res["content-type"] = "text/plain"
ret = "hoge\n"
res.body = ret
end
end
MyCGI.new.start()
==== do_XXX メソッド
do_XXX メソッドの XXX には GET, HEAD, POST, PUT, DELETE, OPTIONS が使用できます。......GET(req, res)
req.query #=> Hash を返します。
req.query['q']
req.query['num']
end
end
MyCGI.new.start()
同じ名前のフィールドが複数ある場合、list メソッドや each_data メソッドを使います。
require "webrick/cgi......GI
def do_GET(req, res)
req.query['q'].list #=> フォームの値を保持した文字列の配列を返します。
end
end
MyCGI.new.start()
query メソッドが返す Hash オブジェクトのキーと値のうち値は WEBrick::HTTPUtils::FormData クラスの
インスタ... -
WEBrick
:: HTTPAuth :: BasicAuth (24.0) -
HTTP の Basic 認証のためのクラスです。
...'s realm"
srv = WEBrick::HTTPServer.new({ :BindAddress => '127.0.0.1', :Port => 10080})
htpd = WEBrick::HTTPAuth::Htpasswd.new('dot.htpasswd')
htpd.set_passwd(nil, 'username', 'supersecretpass')
authenticator = WEBrick::HTTPAuth::BasicAuth.new(:UserDB => htpd, :Realm => realm)......srv.mount_proc('/basic_auth') {|req, res|
authenticator.authenticate(req, res)
res.body = "hoge"
}
srv.start # http://127.0.0.1:10080/basic_auth... -
WEBrick
:: HTTPResponse # content _ length -> Integer | nil (18.0) -
Content-Length ヘッダの値を整数で表すアクセサです。デフォルトは nil です。
...す。nil を指定することは出来ません。
require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion => "1.1" } )
f = File.new('testfile')
res.body = f
res.content_length = 2
print res.to_s
#=> 出力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Dat... -
WEBrick
:: HTTPResponse # content _ length=(len) (18.0) -
Content-Length ヘッダの値を整数で表すアクセサです。デフォルトは nil です。
...す。nil を指定することは出来ません。
require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion => "1.1" } )
f = File.new('testfile')
res.body = f
res.content_length = 2
print res.to_s
#=> 出力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Dat... -
Net
:: HTTPGenericRequest # body -> String (12.0) -
サーバに送るリクエストのエンティティボディを返します。
...クエストのエンティティボディを返します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Post.new(uri.request_uri)
req.body = "Test Post Data"
req.body # => "Test Post Data"
//}
@see Net::HTTPGenericRequest#body=... -
WEBrick
:: HTTPResponse # chunked=(flag) (12.0) -
真に設定するとクライアントに返す内容(エンティティボディ)を chunk に分けるようになります。
...ポンスを chunk に分けてクライアントに返します。
require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion => "1.1" } )
res.body = 'hoge'
res.chunked = true
print res.to_s
#=> 出力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sat, 27 Oc... -
WEBrick
:: HTTPResponse # to _ s -> String (12.0) -
実際にクライアントに送られるデータを文字列として返します。
...ントに送られるデータを文字列として返します。
require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion => "1.1" } )
res.body = 'hoge'
print res.to_s
#=> 出力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sat, 27 Oct 2007 08:58:49 GMT... -
WEBrick
:: HTTPServlet :: AbstractServlet # do _ DELETE(request , response) -> () (12.0) -
自身の service メソッドから HTTP のリクエストに応じて 呼ばれるメソッドです。AbstractServlet のサブクラスはこれらのメソッドを適切に実装し なければいけません。返り値は特に規定されていません。
...:
require 'webrick'
class HogeServlet < WEBrick::HTTPServlet::AbstractServlet
def do_GET(req, res)
res.body = 'hoge'
end
end
srv = WEBrick::HTTPServer.new({ :DocumentRoot => './',
:BindAddress => '127.0.0.1',...