るりまサーチ

最速Rubyリファレンスマニュアル検索!
165件ヒット [1-100件を表示] (0.083秒)

別のキーワード

  1. response new
  2. net/http response
  3. http get_response
  4. imap add_response_handler
  5. net/http get_response

キーワード

検索結果

<< 1 2 > >>

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...

絞り込み条件を変える

<< 1 2 > >>