別のキーワード
ライブラリ
-
net
/ http (44) -
webrick
/ httpresponse (55) -
webrick
/ httpservlet / abstract (66)
クラス
-
Net
:: HTTP (44) -
WEBrick
:: HTTPResponse (55) -
WEBrick
:: HTTPServlet :: AbstractServlet (66)
キーワード
- 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) - get (22)
- post (22)
-
to
_ s (11)
検索結果
先頭5件
-
WEBrick
:: HTTPResponse # body=(val) (21107.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 G... -
WEBrick
:: HTTPResponse # chunked=(flag) (3007.0) -
真に設定するとクライアントに返す内容(エンティティボディ)を chunk に分けるようになります。
...WEBrick::HTTPResponse#request_http_version が 1.0 以下である場合、この値は無視されます。
@param flag true を指定した場合、レスポンスを chunk に分けてクライアントに返します。
require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVe......rsion => "1.1" } )
res.body = 'hoge'
res.chunked = true
print res.to_s
#=> 出力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sat, 27 Oct 2007 09:04:28 GMT
Server:
Transfer-Encoding: chunked
4
hoge
0
#... -
WEBrick
:: HTTPResponse # content _ length -> Integer | nil (3007.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... -
WEBrick
:: HTTPResponse # content _ length=(len) (3007.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... -
WEBrick
:: HTTPResponse # to _ s -> String (3007.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... -
Net
:: HTTP # get(path , header = nil , dest = nil) -> Net :: HTTPResponse (131.0) -
サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。
...サーバ上の path にあるエンティティを取得し、
Net::HTTPResponse のインスタンスとして返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という......されたときは
エンティティボディを少しずつ文字列として
ブロックに与えます。このとき戻り値の
Net::HTTPResponse オブジェクトは有効な body を
持ちません。
dest は時代遅れの引数です。利用しないでください。
dest を指定......なります。
//emlist[例][ruby]{
# net/http version 1.1
response, body = http.get( '/index.html' )
# net/http version 1.2
response = http.get('/index.html')
# compatible in both version
response , = http.get('/index.html')
response.body
# compatible, using block
File.open('save.txt', 'w') {|... -
Net
:: HTTP # get(path , header = nil , dest = nil) {|body _ segment| . . . . } -> Net :: HTTPResponse (131.0) -
サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。
...サーバ上の path にあるエンティティを取得し、
Net::HTTPResponse のインスタンスとして返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という......されたときは
エンティティボディを少しずつ文字列として
ブロックに与えます。このとき戻り値の
Net::HTTPResponse オブジェクトは有効な body を
持ちません。
dest は時代遅れの引数です。利用しないでください。
dest を指定......なります。
//emlist[例][ruby]{
# net/http version 1.1
response, body = http.get( '/index.html' )
# net/http version 1.2
response = http.get('/index.html')
# compatible in both version
response , = http.get('/index.html')
response.body
# compatible, using block
File.open('save.txt', 'w') {|... -
Net
:: HTTP # post(path , data , header = nil , dest = nil) -> Net :: HTTPResponse (119.0) -
サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。
...送ります。
返り値は Net::HTTPResponse のインスタンスです。
ブロックと一緒に呼びだされたときはエンティティボディを少しずつ文字列として
ブロックに与えます。このとき戻り値の HTTPResponse オブジェクトは有効な body を......ブジェクト, そのボディ] となります。
//emlist[例][ruby]{
# net/http version 1.1
response, body = http.post('/cgi-bin/search.rb', 'query=subject&target=ruby')
# version 1.2
response = http.post('/cgi-bin/search.rb', 'query=subject&target=ruby')
# using block
File.open('save.html',... -
Net
:: HTTP # post(path , data , header = nil , dest = nil) {|body _ segment| . . . . } -> Net :: HTTPResponse (119.0) -
サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。
...送ります。
返り値は Net::HTTPResponse のインスタンスです。
ブロックと一緒に呼びだされたときはエンティティボディを少しずつ文字列として
ブロックに与えます。このとき戻り値の HTTPResponse オブジェクトは有効な body を......ブジェクト, そのボディ] となります。
//emlist[例][ruby]{
# net/http version 1.1
response, body = http.post('/cgi-bin/search.rb', 'query=subject&target=ruby')
# version 1.2
response = http.post('/cgi-bin/search.rb', 'query=subject&target=ruby')
# using block
File.open('save.html',... -
WEBrick
:: HTTPServlet :: AbstractServlet # do _ DELETE(request , response) -> () (119.0) -
自身の service メソッドから HTTP のリクエストに応じて 呼ばれるメソッドです。AbstractServlet のサブクラスはこれらのメソッドを適切に実装し なければいけません。返り値は特に規定されていません。
...ジェクトです。
@param response クライアントへのレスポンスを表す WEBrick::HTTPResponse オブジェクトです。
例:
require 'webrick'
class HogeServlet < WEBrick::HTTPServlet::AbstractServlet
def do_GET(req, res)
res.body = 'hoge'
end
end
srv = W...