1133件ヒット
[1-100件を表示]
(0.046秒)
ライブラリ
-
net
/ http (1032)
クラス
-
Net
:: HTTP (312) -
Net
:: HTTPGenericRequest (96) -
Net
:: HTTPResponse (144)
モジュール
-
Net
:: HTTPExceptions (12) -
Net
:: HTTPHeader (444)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) -
CODE
_ CLASS _ TO _ OBJ (12) -
CODE
_ TO _ OBJ (12) - HTTPRequest (12)
- HTTPServerException (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 4 . 0 (9) -
NEWS for Ruby 2
. 5 . 0 (8) - Proxy (12)
- [] (12)
- []= (12)
-
add
_ field (12) -
basic
_ auth (12) - body (24)
- body= (12)
-
body
_ permitted? (12) -
body
_ stream (12) -
body
_ stream= (12) - chunked? (12)
- code (12)
-
content
_ length (12) -
content
_ length= (12) -
content
_ range (12) -
content
_ type (12) -
content
_ type= (12) - delete (12)
- each (12)
-
each
_ capitalized _ name (12) -
each
_ header (12) -
each
_ key (12) -
each
_ name (12) -
each
_ value (12) - entity (12)
- fetch (36)
-
form
_ data= (12) - get (24)
- get2 (24)
-
get
_ fields (12) -
get
_ print (24) - head (12)
- head2 (24)
-
http
_ version (12) - key? (12)
-
local
_ host= (12) -
local
_ port= (12) -
main
_ type (12) - method (24)
- msg (12)
-
net
/ https (12) - path (12)
- post (24)
- post2 (24)
-
proxy
_ basic _ auth (12) - range (12)
- range= (24)
-
range
_ length (12) -
read
_ body (24) -
request
_ body _ permitted? (12) -
request
_ get (24) -
request
_ head (24) -
request
_ post (24) - response (12)
-
response
_ body _ permitted? (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 9 feature (12) -
send
_ request (12) -
set
_ content _ type (12) -
set
_ debug _ output (12) -
set
_ form _ data (12) -
set
_ range (36) - start (24)
-
sub
_ type (12) -
type
_ params (12) - value (12)
検索結果
先頭5件
-
net
/ http (38108.0) -
汎用データ転送プロトコル HTTP を扱うライブラリです。 実装は 2616 に基きます。
...け][ruby]{
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'
req......][ruby]{
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'
re......quire 'uri'
#例1: POSTするだけ
res = Net::HTTP.post_form(URI.parse('http://www.example.com/search'),
{'q'=>'ruby', 'max'=>'50'})
puts res.body
#例2: 認証付きで POST する
res = Net::HTTP.post_form(URI.parse('http://jack:pass@www.example.com/todo.cgi'),... -
Net
:: HTTPHeader # fetch(key) -> String (8054.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-......key , default を指定][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:/... -
Net
:: HTTPHeader # fetch(key) {|hash| . . . . } -> String (8054.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-......key , default を指定][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:/... -
Net
:: HTTPHeader # fetch(key , default) -> String (8054.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-......key , default を指定][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:/... -
Net
:: HTTPHeader # form _ data=(params) (8042.0) -
HTMLのフォームのデータ params から ヘッダフィールドとボディを設定します。
...orm_data][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 = U......RI.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 # set _ form _ data(params , sep = & # 39;&& # 39;) -> () (8042.0) -
HTMLのフォームのデータ params から ヘッダフィールドとボディを設定します。
...orm_data][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 = U......RI.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
:: HTTP # post(path , data , header = nil , dest = nil) -> Net :: HTTPResponse (8030.0) -
サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。
..., そのボディ] となります。
//emlist[例][ruby]{
# net/http version 1.1
response, body = http.post('/cgi-bin/search.rb', 'query=subject&target=ruby')
# version 1.2
response = http.post('/cgi-bin/search.rb', 'query=subject&target=ruby')
# using block
File.open('save.html', 'w') {|f|
ht... -
Net
:: HTTP # post(path , data , header = nil , dest = nil) {|body _ segment| . . . . } -> Net :: HTTPResponse (8030.0) -
サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。
..., そのボディ] となります。
//emlist[例][ruby]{
# net/http version 1.1
response, body = http.post('/cgi-bin/search.rb', 'query=subject&target=ruby')
# version 1.2
response = http.post('/cgi-bin/search.rb', 'query=subject&target=ruby')
# using block
File.open('save.html', 'w') {|f|
ht... -
Net
:: HTTPResponse # value -> nil (8030.0) -
レスポンスが 2xx(成功)でなかった場合に、対応する 例外を発生させます。
...スが 2xx(成功)でなかった場合に、対応する
例外を発生させます。
@raise HTTPError レスポンスが 1xx であるか、 net/http が知らない
種類のレスポンスである場合に発生します。
@raise HTTPRetriableError レスポンスが 3xx......emlist[例 レスポンスが 2xx(成功)][ruby]{
require 'net/http'
uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.value # => nil
//}
//emlist[例 レスポンスが 2xx以外][ruby]{
require 'net/http'
uri = "http://www.example.com/invalid.h...