るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

WEBrick::HTTPResponse#to_s -> String (24108.0)

実際にクライアントに送られるデータを文字列として返します。

...字列として返します。

require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion => "1.1" } )
res.body = 'hoge'
p
rint res.to_s

#=> 出力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sat, 27 Oct 2007 08:58:49 GMT
Server:
Content-Length: 4

hog...

WEBrick::HTTPResponse#http_version -> WEBrick::HTTPVersion (9119.0)

レスポンスの HTTP のバージョンを表す WEBrick::HTTPVersion オブジェクトを返します。

...HTTP のバージョンを表す WEBrick::HTTPVersion オブジェクトを返します。

require 'webrick'
res = WEBrick::HTTPResponse.new( { :HTTPVersion => "1.1" } )
p
res.http_version.class #=> WEBrick::HTTPVersion
p
res.http_version.to_s...

WEBrick::HTTPResponse#[]=(field, val) (6007.0)

レスポンスの該当するヘッダに val を設定します。

...@param field ヘッダ名を文字列で指定します。大文字と小文字を区別しません。

@param val ヘッダの値を指定します。to_s メソッドによって文字列に変換されます。

require 'time'
res['last-modified'] = Time.now.httpdate

@see WEBrick::HTTPRespo...
...nse#chunked?, WEBrick::HTTPResponse#content_length,
WEBrick::HTTPResponse#content_type...

WEBrick::HTTPResponse#body=(val) (6007.0)

クライアントに返す内容(エンティティボディ)をセットします。

...(エンティティボディ)をセットします。

自身が chunked であっても body の値はチャンク形式ではありません。

@param val メッセージボディを文字列か IO オブジェクトで指定します。
自身が chunked であってもチャンク形...
...ーディングされます。

require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion => "1.1" } )
res.body = 'hoge'
p
rint res.to_s

#=> 出力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sat, 27 Oct 2007 08:58:49 GMT
Server:
Content-Length: 4

hog...

WEBrick::HTTPResponse#chunked=(flag) (6007.0)

真に設定するとクライアントに返す内容(エンティティボディ)を chunk に分けるようになります。

...ick::HTTPResponse#request_http_version が 1.0 以下である場合、この値は無視されます。

@param flag true を指定した場合、レスポンスを chunk に分けてクライアントに返します。

require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion...
...=> "1.1" } )
res.body = 'hoge'
res.chunked = true
p
rint 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 (6007.0)

Content-Length ヘッダの値を整数で表すアクセサです。デフォルトは nil です。

...ん。

@param len ヘッダの値を整数で指定します。nil を指定することは出来ません。

require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion => "1.1" } )
f = File.new('testfile')
res.body = f
res.content_length = 2
p
rint res.to_s

#=> 出...
...力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sat, 27 Oct 2007 12:04:32 GMT
Server:
Content-Length: 2

ho...

WEBrick::HTTPResponse#content_length=(len) (6007.0)

Content-Length ヘッダの値を整数で表すアクセサです。デフォルトは nil です。

...ん。

@param len ヘッダの値を整数で指定します。nil を指定することは出来ません。

require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion => "1.1" } )
f = File.new('testfile')
res.body = f
res.content_length = 2
p
rint res.to_s

#=> 出...
...力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sat, 27 Oct 2007 12:04:32 GMT
Server:
Content-Length: 2

ho...