るりまサーチ (Ruby 2.6.0)

最速Rubyリファレンスマニュアル検索!
23件ヒット [1-23件を表示] (0.042秒)
トップページ > バージョン:2.6.0[x] > クエリ:String[x] > クエリ:get[x] > ライブラリ:net/http[x]

別のキーワード

  1. string []=
  2. string []
  3. string slice
  4. string slice!
  5. string gsub

モジュール

キーワード

検索結果

Net::HTTP.get(host, path, port = 80) -> String (54685.0)

指定した対象に GET リクエストを送り、そのボディを 文字列として返します。

指定した対象に GET リクエストを送り、そのボディを
文字列として返します。

対象の指定方法は URI で指定するか、
(host, path, port) で指定するかのいずれかです。

@param uri データの取得対象を URI で指定します。
@param host 接続先のホストを文字列で指定します。
@param path データの存在するパスを文字列で指定します。
@param port 接続するポートを整数で指定します。
@see Net::HTTP#get

Net::HTTP.get(uri) -> String (54685.0)

指定した対象に GET リクエストを送り、そのボディを 文字列として返します。

指定した対象に GET リクエストを送り、そのボディを
文字列として返します。

対象の指定方法は URI で指定するか、
(host, path, port) で指定するかのいずれかです。

@param uri データの取得対象を URI で指定します。
@param host 接続先のホストを文字列で指定します。
@param path データの存在するパスを文字列で指定します。
@param port 接続するポートを整数で指定します。
@see Net::HTTP#get

Net::HTTPHeader#get_fields(key) -> [String] (18649.0)

key ヘッダフィールドの値 (文字列) を配列で返します。

...y は大文字小文字を区別しません。

@param key ヘッダフィール名を文字列で与えます。

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

uri = URI.parse('http://www.example.com/index.html')
res = Net::HTTP.get_response(uri)
res.get_fields('accept-ranges') # => ["none"]
//}

@see...

Net::HTTPResponse#read_body(dest=nil) -> String|nil (382.0)

ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。

...果取得][ruby]{
require 'net/http'

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}

//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'

uri = URI.parse('http:/...

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

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

...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...
...efault を指定][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'

uri = URI.parse('http://www.exa...

絞り込み条件を変える

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

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

...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...
...efault を指定][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'

uri = URI.parse('http://www.exa...

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

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

...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...
...efault を指定][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'

uri = URI.parse('http://www.exa...

Net::HTTPGenericRequest#method -> String (346.0)

リクエストの HTTP メソッドを文字列で返します。

...リクエストの HTTP メソッドを文字列で返します。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Post.new(uri.request_uri)
req.method # => "POST"
req = Net::HTTP::Get.new(uri.request_uri)
req.method # => "GET"
//}...

Net::HTTPHeader#[](key) -> String|nil (346.0)

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

...しては '2048'
のような文字列が得られます。キーが存在しなければ nil を返します。

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

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

一種類のヘ...

Net::HTTPHeader#method -> String (346.0)

リクエストの HTTP メソッドを文字列で返します。

...リクエストの HTTP メソッドを文字列で返します。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.method # => "GET"
//}...

絞り込み条件を変える

Net::HTTPResponse#body -> String | () | nil (331.0)

エンティティボディを返します。

...dapter のインスタンスを返しますが、
これは使わないでください。

entity は obsolete です。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.body[0..10] # => "<!doctype h"
//}...

Net::HTTPResponse#entity -> String | () | nil (331.0)

エンティティボディを返します。

...dapter のインスタンスを返しますが、
これは使わないでください。

entity は obsolete です。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.body[0..10] # => "<!doctype h"
//}...

Net::HTTPResponse#message -> String (331.0)

HTTP サーバがリザルトコードに付加して返すメッセージです。 例えば 'Not Found' などです。

...して返すメッセージです。
例えば 'Not Found' などです。

msg は obsolete です。使わないでください。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.message # => "OK"
//}...

Net::HTTPResponse#msg -> String (331.0)

HTTP サーバがリザルトコードに付加して返すメッセージです。 例えば 'Not Found' などです。

...して返すメッセージです。
例えば 'Not Found' などです。

msg は obsolete です。使わないでください。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.message # => "OK"
//}...

Net::HTTPGenericRequest#path -> String (328.0)

リクエストする path を文字列で返します。

...リクエストする path を文字列で返します。

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

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

絞り込み条件を変える

Net::HTTPHeader#basic_auth(account, password) -> [String] (328.0)

Authorization: ヘッダを BASIC 認証用にセットします。

...unt アカウント名を文字列で与えます。
@param password パスワードを文字列で与えます。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.basic_auth("user", "pass") # => ["Basic dXNl...

Net::HTTPHeader#delete(key) -> [String] | nil (328.0)

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

...ます。
key ヘッダフィールドが存在しなかった場合には
nil を返します。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_length = 10
req.content_length # =>...

Net::HTTPHeader#main_type -> String|nil (328.0)

"text/html" における "text" のようなタイプを表す 文字列を返します。

...タイプを表す
文字列を返します。

Content-Type: ヘッダフィールドが存在しない場合には nil を返します。

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

uri = URI.parse('http://www.example.com/index.html')
res = Net::HTTP.get_response(uri)
res.main_type # => "text"
//}...

Net::HTTPHeader#proxy_basic_auth(account, password) -> [String] (328.0)

Proxy 認証のために Proxy-Authorization: ヘッダをセットします。

...unt アカウント名を文字列で与えます。
@param password パスワードを文字列で与えます。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.proxy_basic_auth("account", "password") # =>...

Net::HTTPHeader#sub_type -> String|nil (328.0)

"text/html" における "html" のようなサブタイプを表す 文字列を返します。

...タイプを表す
文字列を返します。

Content-Type: ヘッダフィールドが存在しない場合には nil を返します。

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

uri = URI.parse('http://www.example.com/index.html')
res = Net::HTTP.get_response(uri)
res.sub_type # => "html"
//}...

絞り込み条件を変える

Net::HTTPResponse#code -> String (328.0)

HTTP のリザルトコードです。例えば '302' などです。

...スオブジェクトがどのクラスのインスタンスかを
見ることでもレスポンスの種類を判別できます。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.code # => "200"
//}...

Net::HTTPResponse#http_version -> String (328.0)

サーバがサポートしている HTTP のバージョンを文字列で返します。

...サーバがサポートしている HTTP のバージョンを文字列で返します。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.http_version # => "1.1"
//}...

Net::HTTPResponse#read_body {|str| .... } -> () (82.0)

ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。

...果取得][ruby]{
require 'net/http'

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}

//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'

uri = URI.parse('http:/...