別のキーワード
種類
- インスタンスメソッド (360)
- ライブラリ (12)
- 特異メソッド (6)
クラス
- Data (6)
-
Net
:: HTTP (228) -
Net
:: HTTPResponse (108) -
Net
:: IMAP :: ResponseError (12)
モジュール
-
Net
:: HTTPExceptions (12)
キーワード
- body (12)
-
close
_ on _ empty _ response= (12) - code (12)
- define (6)
- entity (12)
- get (24)
- get2 (24)
- head (12)
- head2 (24)
-
http
_ version (12) - msg (12)
-
net
/ http (12) - post (24)
- post2 (24)
-
read
_ body (24) -
request
_ get (24) -
request
_ head (24) -
request
_ post (24) - response (12)
-
send
_ request (12) - value (12)
検索結果
先頭5件
-
Net
:: IMAP :: ResponseError # response=(resp) (18100.0) -
エラーとなったレスポンスを表すオブジェクトを設定します。
エラーとなったレスポンスを表すオブジェクトを設定します。
@param resp 設定するレスポンスオブジェクト -
Net
:: HTTP # close _ on _ empty _ response=(bool) (6100.0) -
レスポンスがボディを持っていない場合にコネクションを 閉じるかどうかを設定します。
レスポンスがボディを持っていない場合にコネクションを
閉じるかどうかを設定します。
@param bool レスポンスがボディを持っていない場合にコネクションを
閉じるかどうか指定します。
@see Net::HTTP#close_on_empty_response -
Net
:: HTTP # head(path , header = nil) -> Net :: HTTPResponse (12.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::HTTP#request_head... -
Net
:: HTTPResponse # value -> nil (12.0) -
レスポンスが 2xx(成功)でなかった場合に、対応する 例外を発生させます。
...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.html"
response = Net::HTTP.get_response(URI.parse(uri))
begin... -
net
/ http (12.0) -
汎用データ転送プロトコル HTTP を扱うライブラリです。 実装は 2616 に基きます。
...re 'uri'
def fetch(uri_str, limit = 10)
# You should choose better exception.
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
response = Net::HTTP.get_response(URI.parse(uri_str))
case response
when Net::HTTPSuccess
response
when Net::HTTPRedirection
fetch(response......re 'net/http'
Net::HTTP.start('www.example.com') {|http|
req = Net::HTTP::Get.new('/secret-page.html')
req.basic_auth 'account', 'password'
response = http.request(req)
print response.body
}
//}
=== フォームの値の区切り文字について
POSTで application/x-www-form-urlenc... -
Data
. define(*args) -> Class (6.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...ブクラスも定義可能です。
以下のように、パターンマッチに利用できます。
//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)
NotFound = Data.define
def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(bod... -
Data
. define(*args) {|subclass| block } -> Class (6.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...ブクラスも定義可能です。
以下のように、パターンマッチに利用できます。
//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)
NotFound = Data.define
def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(bod... -
Net
:: HTTP # get(path , header = nil , dest = nil) -> Net :: HTTPResponse (6.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')
response.body
# compatible, using block
File.open('s... -
Net
:: HTTP # get(path , header = nil , dest = nil) {|body _ segment| . . . . } -> Net :: HTTPResponse (6.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')
response.body
# compatible, using block
File.open('s... -
Net
:: HTTP # get2(path , header = nil) -> Net :: HTTPResponse (6.0) -
サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。
...字列で指定します。
@param header リクエストの HTTP ヘッダをハッシュで指定します。
//emlist[例][ruby]{
# example
response = http.request_get('/index.html')
p response['content-type']
puts response.body # body is already read
# using block
http.request_get('/i...