るりまサーチ

最速Rubyリファレンスマニュアル検索!
55件ヒット [1-55件を表示] (0.039秒)
トップページ > クエリ:nil[x] > クエリ:end[x] > クエリ:new[x] > ライブラリ:net/http[x]

別のキーワード

  1. _builtin nil?
  2. nilclass nil?
  3. object nil?
  4. _builtin nil
  5. object nil

クラス

モジュール

キーワード

検索結果

Net::HTTP#local_port=(port) (32.0)

接続に用いるローカルポートを設定します。

...を設定します。

nil
の場合システムが適当にローカルポートを
決めます。

デフォルトは nil です。

@param port ローカルポート(数値、もしくはサービス名文字列)

//emlist[例][ruby]{
require 'net/http'

http = Net::HTTP.new("www.example.com")
h...
...ttp.local_host = "192.168.0.5"
http.local_port = "53043"

http.start do |h|
p h.get("/").body
end

//}

@see Net::HTTP#local_port=, Net::HTTP#local_host


@see Net::HTTP.new...

Net::HTTPHeader#fetch(key) -> String (32.0)

key ヘッダフィールドを返します。

...します。

たとえばキー 'content-length' に対しては '2048'
のような文字列が得られます。キーが存在しなければ nil を返します。

該当するキーが登録されてい
ない時には、引数 default が与えられていればその値を、ブロッ
...
...key が存在する][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("user-agent") # => "Ruby"
//}

//emlist[例 key のみ指定。key が存在しない][ruby]{
require 'net/http'

begin
req.fetch("content-length...
...">
end

//}

//emlist[例 key , default を指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length", "default") # => "default"
//}

//emlist[例 key とブロックを指定][ruby]{
require 'net/http'...

Net::HTTPHeader#fetch(key) {|hash| .... } -> String (32.0)

key ヘッダフィールドを返します。

...します。

たとえばキー 'content-length' に対しては '2048'
のような文字列が得られます。キーが存在しなければ nil を返します。

該当するキーが登録されてい
ない時には、引数 default が与えられていればその値を、ブロッ
...
...key が存在する][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("user-agent") # => "Ruby"
//}

//emlist[例 key のみ指定。key が存在しない][ruby]{
require 'net/http'

begin
req.fetch("content-length...
...">
end

//}

//emlist[例 key , default を指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length", "default") # => "default"
//}

//emlist[例 key とブロックを指定][ruby]{
require 'net/http'...

Net::HTTPHeader#fetch(key, default) -> String (32.0)

key ヘッダフィールドを返します。

...します。

たとえばキー 'content-length' に対しては '2048'
のような文字列が得られます。キーが存在しなければ nil を返します。

該当するキーが登録されてい
ない時には、引数 default が与えられていればその値を、ブロッ
...
...key が存在する][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("user-agent") # => "Ruby"
//}

//emlist[例 key のみ指定。key が存在しない][ruby]{
require 'net/http'

begin
req.fetch("content-length...
...">
end

//}

//emlist[例 key , default を指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length", "default") # => "default"
//}

//emlist[例 key とブロックを指定][ruby]{
require 'net/http'...

Net::HTTP#local_host=(host) (26.0)

接続に用いるローカルホスト名を指定します。

...ト名を指定します。

nil
の場合システムが適当にローカルホストを
決めます。

デフォルトは nil です。

@param host ホスト名、もしくはアドレスを示す文字列

//emlist[例][ruby]{
require 'net/http'

http = Net::HTTP.new("www.example.com")
http.l...
...ocal_host = "192.168.0.5"
http.local_port = "53043"

http.start do |h|
p h.get("/").body
end

//}

@see Net::HTTP#local_host=, Net::HTTP#local_port...

絞り込み条件を変える