ライブラリ
-
net
/ http (664)
クラス
-
Net
:: HTTP (300) -
Net
:: HTTPGenericRequest (84) -
Net
:: HTTPResponse (84)
モジュール
-
Net
:: HTTPHeader (72)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) -
CODE
_ CLASS _ TO _ OBJ (12) -
CODE
_ TO _ OBJ (12) - HTTPBadGateway (12)
- HTTPBadRequest (12)
- HTTPBadResponse (12)
- HTTPForbidden (12)
- HTTPNotAcceptable (12)
- HTTPRangeNotSatisfiable (7)
- HTTPRequestedRangeNotSatisfiable (12)
- HTTPRetriableError (12)
- HTTPServiceUnavailable (12)
- HTTPUnavailableForLegalReasons (9)
- HTTPUnprocessableEntity (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 4 . 0 (9) -
NEWS for Ruby 2
. 5 . 0 (8) - active? (12)
-
add
_ field (12) -
basic
_ auth (12) - body (24)
- body= (12)
-
body
_ exist? (12) -
body
_ permitted? (12) -
body
_ stream (12) -
body
_ stream= (12) - chunked? (12)
-
close
_ on _ empty _ response (12) -
close
_ on _ empty _ response= (12) - entity (12)
- get (12)
- key? (12)
- lock (12)
- mkcol (12)
- move (12)
- patch (12)
- post (12)
- propfind (12)
- proppatch (12)
- proxy? (12)
-
proxy
_ basic _ auth (12) -
proxy
_ class? (12) -
proxy
_ from _ env= (12) -
proxy
_ from _ env? (12) -
read
_ body (24) -
request
_ body _ permitted? (12) -
response
_ body _ permitted? (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 9 feature (12) -
set
_ debug _ output (12) -
ssl
_ version (12) - start (24)
- started? (12)
-
sub
_ type (12) - unlock (12)
-
use
_ ssl= (12) -
use
_ ssl? (12) -
verify
_ callback (12) -
verify
_ callback= (12)
検索結果
先頭5件
-
net
/ http (38054.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'
requir.......html')
}
puts res.body
//}
//emlist[例4: 上の例よりさらに汎用的な例][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'
require '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::... -
Net
:: HTTPGenericRequest # body=(body) (14206.0) -
サーバに送るリクエストのエンティティボディを文字列で設定します。
...。
@param body 設定するボディを文字列で与えます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Post.new(uri.request_uri)
req.body = "Test Post Data" # => "Test Post Data"
//}
@see Net::HTTPGenericRequest#body... -
Net
:: HTTPGenericRequest # request _ body _ permitted? -> bool (14206.0) -
リクエストにエンティティボディを一緒に送ることが許されている HTTP メソッド (POST など)の場合真を返します。
...場合真を返します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
post = Net::HTTP::Post.new(uri.request_uri)
post.request_body_permitted? # => true
head = Net::HTTP::Head.new(uri.request_uri)
head.request_body_permitted? # => false
//}... -
Net
:: HTTPGenericRequest # response _ body _ permitted? -> bool (14206.0) -
サーバからのレスポンスにエンティティボディを含むことが許されている HTTP メソッド (GET, POST など)の場合真を返します。
...合真を返します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
post = Net::HTTP::Post.new(uri.request_uri)
post.response_body_permitted? # => true
head = Net::HTTP::Head.new(uri.request_uri)
head.response_body_permitted? # => false
//}... -
Net
:: HTTPResponse . body _ permitted? -> bool (14206.0) -
エンティティボディを含むことが許されているレスポンスクラス ならば真を、そうでなければ偽を返します。
...エンティティボディを含むことが許されているレスポンスクラス
ならば真を、そうでなければ偽を返します。
//emlist[例][ruby]{
require 'net/http'
Net::HTTPSuccess.body_permitted? # => true
Net::HTTPNotModified.body_permitted? # => false
//}... -
Net
:: HTTPGenericRequest # body _ exist? -> bool (14200.0) -
このメソッドは obsolete です。
...このメソッドは obsolete です。
Net::HTTPGenericRequest#response_body_permitted?
の別名です。... -
Net
:: HTTPResponse # read _ body {|str| . . . . } -> () (14112.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('......th/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 d......ェクトは使わないでください。
dest は obsolete です。使わないでください。
dest を指定した場合には
ボディを少しずつ取得して順次
「dest << ボディの断片」を実行します。
@param dest obsoleteな引数です。利用しないでくださ... -
Net
:: HTTPResponse # read _ body(dest=nil) -> String|nil (14112.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('......th/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 d......ェクトは使わないでください。
dest は obsolete です。使わないでください。
dest を指定した場合には
ボディを少しずつ取得して順次
「dest << ボディの断片」を実行します。
@param dest obsoleteな引数です。利用しないでくださ... -
Net
:: HTTPGenericRequest # body -> String (14106.0) -
サーバに送るリクエストのエンティティボディを返します。
...クエストのエンティティボディを返します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Post.new(uri.request_uri)
req.body = "Test Post Data"
req.body # => "Test Post Data"
//}
@see Net::HTTPGenericRequest#body=...