るりまサーチ

最速Rubyリファレンスマニュアル検索!
128件ヒット [1-100件を表示] (0.041秒)
トップページ > クエリ:path[x] > クエリ:require[x] > クエリ:net/http[x]

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. require execute

検索結果

<< 1 2 > >>

net/http (38132.0)

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

...by]{
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
'u...
...]{
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
...
...=>'2005-03-31'})
puts res.body

#例3: より細かく制御する
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|...

Net::HTTPGenericRequest#path -> String (26135.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::HTTP.get_print(host, path, port = 80) -> () (8143.0)

指定した対象から HTTP でエンティティボディを取得し、 $stdout に出力します。

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

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

=== 例

//emlist[][ruby]{
require
'net/http'
require
'uri'
Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
//}

もしくは

//emlist[][ruby]{
require
'net/http'
Net::HTTP.get_print 'www.example.com', '/index.html'
//}...

Net::HTTP#head(path, header = nil) -> Net::HTTPResponse (8135.0)

サーバ上の path にあるエンティティのヘッダのみを取得します。 Net::HTTPResponse のインスタンスを返します。

...サーバ上の path にあるエンティティのヘッダのみを取得します。
Net::HTTPResponse のインスタンスを返します。

header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*...
...aram path 取得するエンティティのパスを文字列で指定します。
@param header リクエストの HTTP ヘッダをハッシュで指定します。

1.1 互換モードの場合は、レスポンスに応じて例外が発生します。

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

r...

Net::HTTP.get_print(uri) -> () (8043.0)

指定した対象から HTTP でエンティティボディを取得し、 $stdout に出力します。

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

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

=== 例

//emlist[][ruby]{
require
'net/http'
require
'uri'
Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
//}

もしくは

//emlist[][ruby]{
require
'net/http'
Net::HTTP.get_print 'www.example.com', '/index.html'
//}...

絞り込み条件を変える

Net::HTTPResponse#read_body {|str| .... } -> () (8042.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('htt...
...p://www.example.com/path/to/big.file')
Net::HTTP.start(uri.host, uri.port) do |http|
File.open("/path/to/big.file", "w") do |f|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|...

Net::HTTPResponse#read_body(dest=nil) -> String|nil (8042.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('htt...
...p://www.example.com/path/to/big.file')
Net::HTTP.start(uri.host, uri.port) do |http|
File.open("/path/to/big.file", "w") do |f|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|...

Net::HTTPGenericRequest#body_stream -> object (8024.0)

サーバに送るリクエストのエンティティボディを IO オブジェクトなどのストリームで設定します。 f は read(size) メソッドが定義されている必要があります。

...を得るストリームオブジェクトを与えます。

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

uri = URI.parse('http://www.example.com/index.html')
post = Net::HTTP::Post.new(uri.request_uri)
File.open("/path/to/test", 'rb') do |f|
# 大きなファイルを扱う際にメモリ消費を...
...少なくできる
post.body_stream = f
post["Content-Length"] = f.size
end
post.body_stream # => #<File:/path/to/test (closed)>
//}...

Net::HTTPGenericRequest#body_stream=(f) (8024.0)

サーバに送るリクエストのエンティティボディを IO オブジェクトなどのストリームで設定します。 f は read(size) メソッドが定義されている必要があります。

...を得るストリームオブジェクトを与えます。

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

uri = URI.parse('http://www.example.com/index.html')
post = Net::HTTP::Post.new(uri.request_uri)
File.open("/path/to/test", 'rb') do |f|
# 大きなファイルを扱う際にメモリ消費を...
...少なくできる
post.body_stream = f
post["Content-Length"] = f.size
end
post.body_stream # => #<File:/path/to/test (closed)>
//}...

ruby 1.6 feature (120.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...リロードの実行速度が低下するのだそ
うです) ((<ruby-dev:18145>))

: 2002-08-20 File.expand_path

Cygwin 1.3.x ((<ruby-bugs-ja:PR#299>))

p File.expand_path('file', 'c:/')

=> ruby 1.6.7 (2002-03-01) [i586-linux]
/tmp/c:/file
=> ruby 1.6.7 (20...
...-03-22 ((<"net/http">))

Net::HTTP.new がブロックなしのときに nil を返していました。
((<ruby-bugs-ja:PR#214>))

net/protocol は削除される方向にあるようで、その準備時に
エンバグしたそうです。

: 2002-03-20 ((<File/File.expand_path>))

...
...張ライブラリに対して autoload が効いていませんでした。((<ruby-dev:16379>))

autoload :Fcntl, "fcntl"
require
"fcntl"

=> -:2:in `require': uninitialized constant Fcntl (NameError)
from -:2
ruby 1.6.7 (2002-03-01) [i586-linux]

=> ruby 1.6.7 (2...

絞り込み条件を変える

<< 1 2 > >>