るりまサーチ

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

別のキーワード

  1. rexml/document new
  2. rexml/document write
  3. rexml/document clone
  4. rexml/document to_s
  5. rexml/document node_type

検索結果

<< 1 2 3 ... > >>

net/http (38096.0)

汎用データ転送プロトコル HTTP を扱うライブラリです。 実装は 2616 に基きます。

...y]{
require 'net/http'
print Net::HTTP.get('www.example.com', '/index.html')
//}

//emlist[例2: URI を使う][ruby]{
require 'net/http'
require 'uri'
print Net::HTTP.get(URI.parse('http://www.example.com/index.html'))
//}

//emlist[例3: より汎用的な例][ruby]{
require 'net/http'
require 'ur...
...{
require 'net/http'

url = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
puts res.body
//}

==== フォームの情報を送信する (POST)

//emlist[例][ruby]{
require 'net/http'
require '...
...制御する
url = URI.parse('http://www.example.com/todo.cgi')
req = Net::HTTP::Post.new(url.path)
req.basic_auth 'jack', 'pass'
req.set_form_data({'from'=>'2005-01-01', 'to'=>'2005-03-31'})
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
case res
when Net::HTTPSuccess, Ne...

Net::HTTP.new(address, port = 80, proxy_addr = :ENV, proxy_port = nil, proxy_user=nil, proxy_pass=nil) -> Net::HTTP (26101.0)

新しい Net::HTTP オブジェクトを生成します。

新しい Net::HTTP オブジェクトを生成します。

proxy_addr に :ENV を指定すると自動的に環境変数 http_proxy からプロクシの URI を
取り出し利用します。この場合環境変数 http_proxy が定義されていない場合には
プロクシは利用せず直接接続します。
詳しくは URI::Generic#find_proxy を参照してください。

明示的にプロクシのホスト名とポート番号を指定してプロクシを利用することもできます。
このときには proxy_addr にホスト名もしくは IP アドレスを渡します。
このときに proxy_userを指定するとプロク...

Net::HTTP.new(address, port = 80, proxy_addr = :ENV, proxy_port = nil, proxy_user=nil, proxy_pass=nil, no_proxy=nil) -> Net::HTTP (26101.0)

新しい Net::HTTP オブジェクトを生成します。

新しい Net::HTTP オブジェクトを生成します。

proxy_addr に :ENV を指定すると自動的に環境変数 http_proxy からプロクシの URI を
取り出し利用します。この場合環境変数 http_proxy が定義されていない場合には
プロクシは利用せず直接接続します。
詳しくは URI::Generic#find_proxy を参照してください。

明示的にプロクシのホスト名とポート番号を指定してプロクシを利用することもできます。
このときには proxy_addr にホスト名もしくは IP アドレスを渡します。
このときに proxy_userを指定するとプロク...

Net::HTTPRequest.new(path, initheader = nil) -> Net::HTTPRequest (26101.0)

HTTP リクエストオブジェクトを生成します。

HTTP リクエストオブジェクトを生成します。

initheader でリクエストヘッダを指定することができます。
{ヘッダフィールド名(文字列)=>その中身(文字列)} という
Hash を用います。

@param path リクエストする path を文字列で与えます。
@param initheader リクエストヘッダをハッシュで指定します。

Net::HTTPHeader#fetch(key) -> String (8042.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...
...mple.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length") { |e| 99 } # => 99
//}

@see Net::HTTPHeader#[]...

絞り込み条件を変える

Net::HTTPHeader#fetch(key) {|hash| .... } -> String (8042.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...
...mple.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length") { |e| 99 } # => 99
//}

@see Net::HTTPHeader#[]...

Net::HTTPHeader#fetch(key, default) -> String (8042.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...
...mple.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length") { |e| 99 } # => 99
//}

@see Net::HTTPHeader#[]...

Net::HTTP.Proxy(address, port = 80) -> Class (8024.0)

Proxy 経由で http サーバに接続するためのクラスを作成し返します。

...TP.new を使う][ruby]{
require 'net/http'
proxy_class = Net::HTTP::Proxy('proxy.example.com', 8080)
http = proxy_class.new('www.example.org')
http.start {|h|
h.get('/ja/') # proxy.example.com 経由で接続します。
}
//}

//emlist[例2: Net::HTTP.start を使う][ruby]{
require 'net/http'
p...

Net::HTTPHeader#form_data=(params) (8024.0)

HTMLのフォームのデータ params から ヘッダフィールドとボディを設定します。

...][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.form_data = {"q" => ["ruby", "perl"], "lang" => "en"} # => {"q"=>["ruby", "perl"], "lang"=>"en"}
//}

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

uri = URI.parse...
...('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.set_form_data({"q" => "ruby", "lang" => "en"}, ';') # => "application/x-www-form-urlencoded"
//}...

Net::HTTPHeader#range -> Range|nil (8024.0)

Range: ヘッダの示す範囲を Range オブジェクトで返します。

...ist[例 正常な値][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req['range'] = "bytes=1-5"
req.range # => [1..5]
//}

//emlist[例 Net::HTTPHeaderSyntaxError][ruby]{
require 'net/http'

uri = URI.parse('http://www.exampl...
...e.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req['range'] = "invalid"
req.range # => Net::HTTPHeaderSyntaxError
//}...

絞り込み条件を変える

<< 1 2 3 ... > >>