クラス
-
Net
:: HTTP (25) -
Net
:: HTTPGenericRequest (9) -
Net
:: HTTPResponse (2)
モジュール
-
Net
:: HTTPHeader (27)
キーワード
- [] (1)
- []= (1)
-
add
_ field (1) -
basic
_ auth (1) - body (1)
- body= (1)
-
body
_ exist? (1) -
body
_ stream (1) -
body
_ stream= (1) - chunked? (1)
-
content
_ length (1) -
content
_ length= (1) -
content
_ range (1) -
content
_ type (1) -
content
_ type= (1) - delete (1)
- each (1)
-
each
_ capitalized _ name (1) -
each
_ header (1) -
each
_ key (1) -
each
_ name (1) -
each
_ value (1) - fetch (3)
-
form
_ data= (1) - get (2)
- get2 (2)
- head (1)
- head2 (2)
- method (2)
- path (1)
- post (2)
- post2 (2)
-
proxy
_ basic _ auth (1) - put (1)
- put2 (2)
- range (1)
-
range
_ length (1) -
read
_ body (2) -
request
_ body _ permitted? (1) -
request
_ get (2) -
request
_ head (2) -
request
_ post (2) -
request
_ put (2) -
response
_ body _ permitted? (1) -
send
_ request (1) -
set
_ content _ type (1) -
set
_ form _ data (1)
検索結果
先頭5件
- Net
:: HTTP # request(request , data = nil) -> Net :: HTTPResponse - Net
:: HTTP # request(request , data = nil) {|response| . . . . } -> Net :: HTTPResponse - Net
:: HTTPGenericRequest # request _ body _ permitted? -> bool - Net
:: HTTP # send _ request(name , path , data = nil , header = nil) -> Net :: HTTPResponse - Net
:: HTTP # request _ get(path , header = nil) -> Net :: HTTPResponse
-
Net
:: HTTP # request(request , data = nil) -> Net :: HTTPResponse (64024.0) -
Net::HTTPRequest オブジェクト request をサーバに送信します。
Net::HTTPRequest オブジェクト request をサーバに送信します。
POST/PUT の時は data も与えられます
(GET/HEAD などで data を与えると
ArgumentError を発生します)。
ブロックとともに呼びだされたときは
ソケットからボディを読みこまずに Net::HTTPResponse
オブジェクトをブロックに与えます。
@param request リクエストオブジェクトを与えます。
@param data リクエストのボディを文字列で与えます。
@raise ArgumentError dataを与えるべきでないリクエス... -
Net
:: HTTP # request(request , data = nil) {|response| . . . . } -> Net :: HTTPResponse (64024.0) -
Net::HTTPRequest オブジェクト request をサーバに送信します。
Net::HTTPRequest オブジェクト request をサーバに送信します。
POST/PUT の時は data も与えられます
(GET/HEAD などで data を与えると
ArgumentError を発生します)。
ブロックとともに呼びだされたときは
ソケットからボディを読みこまずに Net::HTTPResponse
オブジェクトをブロックに与えます。
@param request リクエストオブジェクトを与えます。
@param data リクエストのボディを文字列で与えます。
@raise ArgumentError dataを与えるべきでないリクエス... -
Net
:: HTTPGenericRequest # request _ body _ permitted? -> bool (36505.0) -
リクエストにエンティティボディを一緒に送ることが許されている HTTP メソッド (POST など)の場合真を返します。
...ディを一緒に送ることが許されている
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 # send _ request(name , path , data = nil , header = nil) -> Net :: HTTPResponse (27733.0) -
HTTP リクエストをサーバに送り、そのレスポンスを Net::HTTPResponse のインスタンスとして返します。
HTTP リクエストをサーバに送り、そのレスポンスを
Net::HTTPResponse のインスタンスとして返します。
@param name リクエストのメソッド名を文字列で与えます。
@param path リクエストのパスを文字列で与えます。
@param data リクエストのボディを文字列で与えます。
@param header リクエストのヘッダをハッシュで与えます。
//emlist[例][ruby]{
response = http.send_request('GET', '/index.html')
puts response.body
//}
@see Net::H... -
Net
:: HTTP # request _ get(path , header = nil) -> Net :: HTTPResponse (18742.0) -
サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。
サーバ上の path にあるエンティティを取得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
エンティティボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
大きなサイズのボディを一度に読みだすとまずく、
小さなサイズに分けて取... -
Net
:: HTTP # request _ get(path , header = nil) {|response| . . . . } -> Net :: HTTPResponse (18742.0) -
サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。
サーバ上の path にあるエンティティを取得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
エンティティボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
大きなサイズのボディを一度に読みだすとまずく、
小さなサイズに分けて取... -
Net
:: HTTP # request _ head(path , header = nil) -> Net :: HTTPResponse (18742.0) -
サーバ上の path にあるエンティティのヘッダのみを取得します。 Net::HTTPResponse オブジェクトを返します。
サーバ上の path にあるエンティティのヘッダのみを取得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
Net::HTTP#request_get と同じ動作を
しますが、そもそもヘッダしか要求していないので
body は空です。そのためこの動作はそれほど意味はありません。
@param path ヘ... -
Net
:: HTTP # request _ head(path , header = nil) {|response| . . . . } -> Net :: HTTPResponse (18742.0) -
サーバ上の path にあるエンティティのヘッダのみを取得します。 Net::HTTPResponse オブジェクトを返します。
サーバ上の path にあるエンティティのヘッダのみを取得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
Net::HTTP#request_get と同じ動作を
しますが、そもそもヘッダしか要求していないので
body は空です。そのためこの動作はそれほど意味はありません。
@param path ヘ... -
Net
:: HTTP # request _ post(path , data , header = nil) -> Net :: HTTPResponse (18742.0) -
サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。 返り値は Net::HTTPResponse のインスタンスです。
サーバ上の path にあるエンティティに対し文字列 data を
POST で送ります。
返り値は Net::HTTPResponse のインスタンスです。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
エンティティボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
POST する場合にはヘッ... -
Net
:: HTTP # request _ post(path , data , header = nil) {|response| . . . . } -> Net :: HTTPResponse (18742.0) -
サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。 返り値は Net::HTTPResponse のインスタンスです。
サーバ上の path にあるエンティティに対し文字列 data を
POST で送ります。
返り値は Net::HTTPResponse のインスタンスです。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
エンティティボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
POST する場合にはヘッ... -
Net
:: HTTP # request _ put(path , data , initheader = nil) -> Net :: HTTPResponse (18652.0) -
サーバ上の path にあるエンティティに対し文字列 data を PUT で送ります。
サーバ上の path にあるエンティティに対し文字列 data を
PUT で送ります。
返り値は Net::HTTPResponse のインスタンスです。
ブロックとともに呼び出されたときは、
ボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
@param path 取得するエンティティのパスを文字列で指定します。
@param data 送るデータを文字列で指定します。
@param initheader リクエストの HTTP ヘッダをハッシュで指定します。
put2 は時代遅れなので使わないでくださ... -
Net
:: HTTP # request _ put(path , data , initheader = nil) {|response| . . . . } -> Net :: HTTPResponse (18652.0) -
サーバ上の path にあるエンティティに対し文字列 data を PUT で送ります。
サーバ上の path にあるエンティティに対し文字列 data を
PUT で送ります。
返り値は Net::HTTPResponse のインスタンスです。
ブロックとともに呼び出されたときは、
ボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
@param path 取得するエンティティのパスを文字列で指定します。
@param data 送るデータを文字列で指定します。
@param initheader リクエストの HTTP ヘッダをハッシュで指定します。
put2 は時代遅れなので使わないでくださ... -
Net
:: HTTPGenericRequest # method -> String (18166.0) -
リクエストの HTTP メソッドを文字列で返します。
...リクエストの HTTP メソッドを文字列で返します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Post.new(uri.request_uri)
req.method # => "POST"
req = Net::HTTP::Get.new(uri.request_uri)
req.method # => "GET"
//}... -
Net
:: HTTPGenericRequest # response _ body _ permitted? -> bool (18166.0) -
サーバからのレスポンスにエンティティボディを含むことが許されている HTTP メソッド (GET, POST など)の場合真を返します。
...ボディを含むことが許されている
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
:: HTTPGenericRequest # body -> String (18082.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::HTTPGe... -
Net
:: HTTPGenericRequest # body=(body) (18082.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... -
Net
:: HTTPGenericRequest # body _ stream -> object (18082.0) -
サーバに送るリクエストのエンティティボディを IO オブジェクトなどのストリームで設定します。 f は read(size) メソッドが定義されている必要があります。
...。
@param f エンティティボディのデータを得るストリームオブジェクトを与えます。
//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|
# 大... -
Net
:: HTTPGenericRequest # body _ stream=(f) (18082.0) -
サーバに送るリクエストのエンティティボディを IO オブジェクトなどのストリームで設定します。 f は read(size) メソッドが定義されている必要があります。
...。
@param f エンティティボディのデータを得るストリームオブジェクトを与えます。
//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|
# 大... -
Net
:: HTTPGenericRequest # path -> String (18082.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
:: HTTPGenericRequest # body _ exist? -> bool (18010.0) -
このメソッドは obsolete です。
このメソッドは obsolete です。
Net::HTTPGenericRequest#response_body_permitted?
の別名です。 -
Net
:: HTTP # get(path , header = nil , dest = nil) -> Net :: HTTPResponse (9490.0) -
サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。
...、返り値が [レスポンスオブジェクト, そのボディ] となります。
//emlist[例][ruby]{
# net/http version 1.1
response, body = http.get( '/index.html' )
# net/http version 1.2
response = http.get('/index.html')
# compatible in both version
response , = http.get('/index.html'... -
Net
:: HTTP # get(path , header = nil , dest = nil) {|body _ segment| . . . . } -> Net :: HTTPResponse (9490.0) -
サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。
...、返り値が [レスポンスオブジェクト, そのボディ] となります。
//emlist[例][ruby]{
# net/http version 1.1
response, body = http.get( '/index.html' )
# net/http version 1.2
response = http.get('/index.html')
# compatible in both version
response , = http.get('/index.html'... -
Net
:: HTTP # head(path , header = nil) -> Net :: HTTPResponse (9454.0) -
サーバ上の path にあるエンティティのヘッダのみを取得します。 Net::HTTPResponse のインスタンスを返します。
...ュで指定します。
1.1 互換モードの場合は、レスポンスに応じて例外が発生します。
//emlist[例][ruby]{
require 'net/http'
response = nil
Net::HTTP.start('some.www.server', 80) {|http|
response = http.head('/index.html')
}
p response['content-type']
//}
@see Net:... -
Net
:: HTTP # get2(path , header = nil) -> Net :: HTTPResponse (9442.0) -
サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。
サーバ上の path にあるエンティティを取得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
エンティティボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
大きなサイズのボディを一度に読みだすとまずく、
小さなサイズに分けて取... -
Net
:: HTTP # get2(path , header = nil) {|response| . . . . } -> Net :: HTTPResponse (9442.0) -
サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。
サーバ上の path にあるエンティティを取得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
エンティティボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
大きなサイズのボディを一度に読みだすとまずく、
小さなサイズに分けて取... -
Net
:: HTTP # head2(path , header = nil) -> Net :: HTTPResponse (9442.0) -
サーバ上の path にあるエンティティのヘッダのみを取得します。 Net::HTTPResponse オブジェクトを返します。
サーバ上の path にあるエンティティのヘッダのみを取得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
Net::HTTP#request_get と同じ動作を
しますが、そもそもヘッダしか要求していないので
body は空です。そのためこの動作はそれほど意味はありません。
@param path ヘ... -
Net
:: HTTP # head2(path , header = nil) {|response| . . . . } -> Net :: HTTPResponse (9442.0) -
サーバ上の path にあるエンティティのヘッダのみを取得します。 Net::HTTPResponse オブジェクトを返します。
サーバ上の path にあるエンティティのヘッダのみを取得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
Net::HTTP#request_get と同じ動作を
しますが、そもそもヘッダしか要求していないので
body は空です。そのためこの動作はそれほど意味はありません。
@param path ヘ... -
Net
:: HTTP # post2(path , data , header = nil) -> Net :: HTTPResponse (9442.0) -
サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。 返り値は Net::HTTPResponse のインスタンスです。
サーバ上の path にあるエンティティに対し文字列 data を
POST で送ります。
返り値は Net::HTTPResponse のインスタンスです。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
エンティティボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
POST する場合にはヘッ... -
Net
:: HTTP # post2(path , data , header = nil) {|response| . . . . } -> Net :: HTTPResponse (9442.0) -
サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。 返り値は Net::HTTPResponse のインスタンスです。
サーバ上の path にあるエンティティに対し文字列 data を
POST で送ります。
返り値は Net::HTTPResponse のインスタンスです。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブロックとともに呼び出されたときは、
エンティティボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
POST する場合にはヘッ... -
Net
:: HTTP # post(path , data , header = nil , dest = nil) -> Net :: HTTPResponse (9436.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... -
Net
:: HTTP # post(path , data , header = nil , dest = nil) {|body _ segment| . . . . } -> Net :: HTTPResponse (9436.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... -
Net
:: HTTP # put(path , data , initheader = nil) -> Net :: HTTPResponse (9364.0) -
サーバ上の path にあるエンティティに対し文字列 data を PUT で送ります。
サーバ上の path にあるエンティティに対し文字列 data を
PUT で送ります。
返り値は Net::HTTPResponse のインスタンスです。
@param path 取得するエンティティのパスを文字列で指定します。
@param data 送るデータを文字列で指定します。
@param initheader リクエストの HTTP ヘッダをハッシュで指定します。
@see Net::HTTP#request_put
1.1 互換モードの場合は、レスポンスに応じて例外が発生します。 -
Net
:: HTTP # put2(path , data , initheader = nil) -> Net :: HTTPResponse (9352.0) -
サーバ上の path にあるエンティティに対し文字列 data を PUT で送ります。
サーバ上の path にあるエンティティに対し文字列 data を
PUT で送ります。
返り値は Net::HTTPResponse のインスタンスです。
ブロックとともに呼び出されたときは、
ボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
@param path 取得するエンティティのパスを文字列で指定します。
@param data 送るデータを文字列で指定します。
@param initheader リクエストの HTTP ヘッダをハッシュで指定します。
put2 は時代遅れなので使わないでくださ... -
Net
:: HTTP # put2(path , data , initheader = nil) {|response| . . . . } -> Net :: HTTPResponse (9352.0) -
サーバ上の path にあるエンティティに対し文字列 data を PUT で送ります。
サーバ上の path にあるエンティティに対し文字列 data を
PUT で送ります。
返り値は Net::HTTPResponse のインスタンスです。
ブロックとともに呼び出されたときは、
ボディをソケットから読み出す前に、
接続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
@param path 取得するエンティティのパスを文字列で指定します。
@param data 送るデータを文字列で指定します。
@param initheader リクエストの HTTP ヘッダをハッシュで指定します。
put2 は時代遅れなので使わないでくださ... -
Net
:: HTTPHeader # fetch(key) -> String (9244.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-length......efault を指定][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://www.exa... -
Net
:: HTTPHeader # fetch(key) {|hash| . . . . } -> String (9244.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-length......efault を指定][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://www.exa... -
Net
:: HTTPHeader # fetch(key , default) -> String (9244.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-length......efault を指定][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://www.exa... -
Net
:: HTTPResponse # read _ body {|str| . . . . } -> () (9244.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('http:/... -
Net
:: HTTPResponse # read _ body(dest=nil) -> String|nil (9244.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('http:/... -
Net
:: HTTPHeader # add _ field(key , val) -> () (9172.0) -
key ヘッダフィールドに val を追加します。
key ヘッダフィールドに val を追加します。
key に元々設定されていた値は破棄されず、それに val 追加されます。
@param key ヘッダフィール名を文字列で与えます。
@param val keyで指定したフィールドに追加する文字列を与えます。
@see Net::HTTPHeader#[] , Net::HTTPHeader#[]=,
Net::HTTPHeader#get_fields
//emlist[例][ruby]{
request.add_field 'X-My-Header', 'a'
p request['X-My-Header'] ... -
Net
:: HTTPHeader # form _ data=(params) (9154.0) -
HTMLのフォームのデータ params から ヘッダフィールドとボディを設定します。
...][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 = URI.parse... -
Net
:: HTTPHeader # range -> Range|nil (9154.0) -
Range: ヘッダの示す範囲を Range オブジェクトで返します。
...ist[例 正常な値][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req['range'] = "bytes=1-5"
req.range # => [1..5]
//}
//emlist[例 Net::HTTPHeaderSyntaxError][ruby]{
require 'net/http'
uri = URI.parse('http://www.exampl... -
Net
:: HTTPHeader # set _ form _ data(params , sep = & # 39;&& # 39;) -> () (9154.0) -
HTMLのフォームのデータ params から ヘッダフィールドとボディを設定します。
...][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 = URI.parse... -
Net
:: HTTPHeader # method -> String (9130.0) -
リクエストの HTTP メソッドを文字列で返します。
...リクエストの HTTP メソッドを文字列で返します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.method # => "GET"
//}... -
Net
:: HTTPHeader # [](key) -> String|nil (9082.0) -
key ヘッダフィールドを返します。
...しては '2048'
のような文字列が得られます。キーが存在しなければ nil を返します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req['user-agent'] # => Ruby
//}
一種類のヘ... -
Net
:: HTTPHeader # []=(key , val) (9082.0) -
key ヘッダフィールドに文字列 val をセットします。
...字列で与えます。
@param val keyで指定したフィールドにセットする文字列を与えます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req['user-agent'] # => Ruby
req['user-agent'] =... -
Net
:: HTTPHeader # basic _ auth(account , password) -> [String] (9082.0) -
Authorization: ヘッダを BASIC 認証用にセットします。
...unt アカウント名を文字列で与えます。
@param password パスワードを文字列で与えます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.basic_auth("user", "pass") # => ["Basic dXNl... -
Net
:: HTTPHeader # chunked? -> bool (9082.0) -
Transfer-Encoding: ヘッダフィールドが "chunked" である 場合に真を返します。
...ヘッダフィールドが存在しなかったり、
"chunked" 以外である場合には偽を返します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.chunked? # => false
req["Transfer-Encoding"]... -
Net
:: HTTPHeader # content _ length -> Integer|nil (9082.0) -
Content-Length: ヘッダフィールドの表している値を整数で返します。
...rSyntaxError フィールドの値が不正である場合に
発生します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_length # => nil
req.content_length... -
Net
:: HTTPHeader # content _ length=(len) (9082.0) -
Content-Length: ヘッダフィールドに値を設定します。
...tent-Length: ヘッダフィールドを
削除します。
@param len 設定する値を整数で与えます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_length # => nil
req.content_len... -
Net
:: HTTPHeader # content _ range -> Range|nil (9082.0) -
Content-Range: ヘッダフィールドの値を Range で返します。 Range の表わす長さは Net::HTTPHeader#range_length で得られます。
...Header#range_length で得られます。
ヘッダが設定されていない場合には nil を返します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_range # => nil
req['Content-Ran... -
Net
:: HTTPHeader # content _ type -> String|nil (9082.0) -
"text/html" のような Content-Type を表す 文字列を返します。
...列を返します。
Content-Type: ヘッダフィールドが存在しない場合には nil を返します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/comments.cgi?post=comment')
req = Net::HTTP::Post.new(uri.request_uri)
req.content_type # => nil
req.c... -
Net
:: HTTPHeader # content _ type=(type) (9082.0) -
type と params から Content-Type: ヘッダフィールドの 値を設定します。
...タイプを文字列で指定します。
@param params パラメータ属性をハッシュで指定します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_type # => n... -
Net
:: HTTPHeader # delete(key) -> [String] | nil (9082.0) -
key ヘッダフィールドを削除します。
...ます。
key ヘッダフィールドが存在しなかった場合には
nil を返します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_length = 10
req.content_length # =>... -
Net
:: HTTPHeader # each {|name , val| . . . . } -> () (9082.0) -
保持しているヘッダ名とその値をそれぞれ ブロックに渡して呼びだします。
...名は小文字で統一されます。
val は ", " で連結した文字列がブロックに渡されます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_header { |key,value| puts "#{key} = #{va... -
Net
:: HTTPHeader # each _ capitalized _ name {|name| . . . . } -> () (9082.0) -
保持しているヘッダ名を正規化 ('x-my-header' -> 'X-My-Header') して、ブロックに渡します。
...持しているヘッダ名を正規化
('x-my-header' -> 'X-My-Header')
して、ブロックに渡します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_capitalized_name { |key| puts key }
# =... -
Net
:: HTTPHeader # each _ header {|name , val| . . . . } -> () (9082.0) -
保持しているヘッダ名とその値をそれぞれ ブロックに渡して呼びだします。
...名は小文字で統一されます。
val は ", " で連結した文字列がブロックに渡されます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_header { |key,value| puts "#{key} = #{va... -
Net
:: HTTPHeader # each _ key {|name| . . . } -> () (9082.0) -
保持しているヘッダ名をブロックに渡して呼びだします。
...るヘッダ名をブロックに渡して呼びだします。
ヘッダ名は小文字で統一されます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_name { |name| puts name }
# => accept-e... -
Net
:: HTTPHeader # each _ name {|name| . . . } -> () (9082.0) -
保持しているヘッダ名をブロックに渡して呼びだします。
...るヘッダ名をブロックに渡して呼びだします。
ヘッダ名は小文字で統一されます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_name { |name| puts name }
# => accept-e... -
Net
:: HTTPHeader # each _ value {|value| . . . . } -> () (9082.0) -
保持しているヘッダの値をブロックに渡し、呼びだします。
...値をブロックに渡し、呼びだします。
渡される文字列は ", " で連結したものです。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_value { |value| puts value }
# => gzip;... -
Net
:: HTTPHeader # proxy _ basic _ auth(account , password) -> [String] (9082.0) -
Proxy 認証のために Proxy-Authorization: ヘッダをセットします。
...unt アカウント名を文字列で与えます。
@param password パスワードを文字列で与えます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.proxy_basic_auth("account", "password") # =>... -
Net
:: HTTPHeader # range _ length -> Integer|nil (9082.0) -
Content-Range: ヘッダフィールドの表している長さを整数で返します。
...不正である場合に
発生します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req['Content-Range'] = "bytes 1-500/1000"
req.rang... -
Net
:: HTTPHeader # set _ content _ type(type , params = {}) (9082.0) -
type と params から Content-Type: ヘッダフィールドの 値を設定します。
...タイプを文字列で指定します。
@param params パラメータ属性をハッシュで指定します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_type # => n...