120件ヒット
[1-100件を表示]
(0.184秒)
クラス
-
Net
:: HTTPGenericRequest (36) -
Net
:: HTTPResponse (24) - OptionParser (24)
-
URI
:: Generic (24) -
URI
:: HTTP (12)
キーワード
-
body
_ stream (12) -
body
_ stream= (12) -
program
_ name (12) -
program
_ name= (12) -
read
_ body (24) -
request
_ uri (12) - select (12)
検索結果
先頭5件
-
URI
:: Generic # path -> String | nil (24266.0) -
自身の path を文字列で返します。設定されていない場合は nil を返します。
...自身の path を文字列で返します。設定されていない場合は nil を返します。
require 'uri'
p URI.parse('http://example.com/hoge').path #=> "/hoge"
p URI.parse('http://example.com').path #=> ""
p URI.parse('mailto:nospam@localhost').path #=> n......il
p URI('ftp://example.com/foo').path #=> 'foo'
p URI('ftp://example.com/%2Ffoo').path #=> '/foo'... -
Net
:: HTTPGenericRequest # path -> String (24230.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"
//}... -
URI
:: HTTP # request _ uri -> String (6151.0) -
自身の「path + '?' + query」を文字列で返します。 query が nil である場合は、自身の path を返します。
...の「path + '?' + query」を文字列で返します。
query が nil である場合は、自身の path を返します。
path が空である場合には、path は「'/'」であるとします。
例:
require 'uri'
u = URI.parse("http://example.com/search?q=xxx")
p u.request_uri... -
Net
:: HTTPGenericRequest # body _ stream -> object (6119.0) -
サーバに送るリクエストのエンティティボディを IO オブジェクトなどのストリームで設定します。 f は read(size) メソッドが定義されている必要があります。
...mlist[例][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) (6119.0) -
サーバに送るリクエストのエンティティボディを IO オブジェクトなどのストリームで設定します。 f は read(size) メソッドが定義されている必要があります。
...mlist[例][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)>
//}... -
URI
:: Generic # select(*components) -> [String] (6113.0) -
指定された components に対応する構成要素を文字列の配列として返します。
...た components に対応する構成要素を文字列の配列として返します。
@param components 構成要素名をシンボルで指定します。
例:
require 'uri'
uri = URI.parse('http://myuser:mypass@my.example.com/test.rbx')
p uri.select(:userinfo, :host, :path)
# => ["m......yuser:mypass", "my.example.com", "/test.rbx"]... -
OptionParser
# program _ name -> String (6107.0) -
プログラムの名前を文字列で返します。
...字列で返します。
デフォルトは $0 が使われます。
@return プログラムの名前を文字列で返します。
//emlist[例][ruby]{
require "optparse"
OptionParser.new do |opts|
p $0 # => /path/to/filename.rb
p opts.program_name # => filename
end
//}... -
OptionParser
# program _ name=(name) (6007.0) -
プログラムの名前を文字列で指定します。
...名前を文字列で指定します。
//emlist[例][ruby]{
require "optparse"
OptionParser.new do |opts|
$0 # => /path/to/filename.rb
opts.program_name # => filename
opts.program_name = 'test' # => "test"
opts.program_name # => "test"
end
//}... -
Net
:: HTTPResponse # read _ body {|str| . . . . } -> () (3131.0) -
ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。
...nil を返します。
//emlist[例1 ブロックを与えずに一度に結果取得][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 ブロックを与えて大......t/http'
uri = URI.parse('http://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|
response.read_body do |s|
f.write(s)
end
end
end
end
//}
一度ブロックを与えずにこのメソッドを呼んだ場合には、
次からはすでに読みだしたボディを文字列として
返します。また一度ブロックを与...