るりまサーチ

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

別のキーワード

  1. net/smtp start
  2. net/http get
  3. net/imap param
  4. net/imap name
  5. net/http start

検索結果

<< 1 2 > >>

net/http (38072.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 '...
...dr や proxy_port
を指定することでプログラムからプロクシを指定することもできます。

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

proxy_addr = 'your.proxy.host'
proxy_port = 8080

Net::HTTP.new('example.com', nil, proxy_addr, proxy_port).start { |http|
# always proxy via...

Net::HTTP.get_print(host, path, port = 80) -> () (14126.0)

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

...ートを整数で指定します。
@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.get_print(uri) -> () (14126.0)

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

...ートを整数で指定します。
@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::HTTPRequest (8012.0)

HTTP リクエストを抽象化するクラスです。

...opfind
* Net::HTTP::Patch
* Net::HTTP::Proppatch
* Net::HTTP::Trace
* Net::HTTP::Unlock

を使用してください。

=== 例

//emlist[][ruby]{
require 'net/http'
http = Net::HTTP.new('www.example.com', 80)
req = Net::HTTP::Get.new('/somefile')
res = http.request(req)
print
res.body
//}...

Net::HTTP#get2(path, header = nil) -> Net::HTTPResponse (8006.0)

サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。

...# body is already read

# using block
http.request_get('/index.html') {|response|
p response['content-type']
response.read_body do |str| # read body now
print
str
end
}
//}

get2 は時代遅れなので使わないでください。

@see Net::HTTP#get, Net::HTTPResponse#read_body...

絞り込み条件を変える

Net::HTTP#get2(path, header = nil) {|response| .... } -> Net::HTTPResponse (8006.0)

サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。

...# body is already read

# using block
http.request_get('/index.html') {|response|
p response['content-type']
response.read_body do |str| # read body now
print
str
end
}
//}

get2 は時代遅れなので使わないでください。

@see Net::HTTP#get, Net::HTTPResponse#read_body...

Net::HTTP#post2(path, data, header = nil) -> Net::HTTPResponse (8006.0)

サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。 返り値は Net::HTTPResponse のインスタンスです。

...se.body # body is already read

# using block
http.request_post('/cgi-bin/nice.rb', 'datadatadata...') {|response|
p response.status
p response['content-type']
response.read_body do |str| # read body now
print
str
end
}
//}

@see Net::HTTP#post, Net::HTTPResponse#read_body...

Net::HTTP#post2(path, data, header = nil) {|response| .... } -> Net::HTTPResponse (8006.0)

サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。 返り値は Net::HTTPResponse のインスタンスです。

...se.body # body is already read

# using block
http.request_post('/cgi-bin/nice.rb', 'datadatadata...') {|response|
p response.status
p response['content-type']
response.read_body do |str| # read body now
print
str
end
}
//}

@see Net::HTTP#post, Net::HTTPResponse#read_body...

Net::HTTP#request_get(path, header = nil) -> Net::HTTPResponse (8006.0)

サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。

...# body is already read

# using block
http.request_get('/index.html') {|response|
p response['content-type']
response.read_body do |str| # read body now
print
str
end
}
//}

get2 は時代遅れなので使わないでください。

@see Net::HTTP#get, Net::HTTPResponse#read_body...
<< 1 2 > >>