D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Net
/
HTTP
/
Filename :
start-c.ri
back
Copy
U:RDoc::AnyMethod[iI" start:ETI"Net::HTTP::start;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"ACreates a new \Net::HTTP object, +http+, via \Net::HTTP.new:;To:RDoc::Markup::BlankLine o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I";For arguments +address+ and +port+, see Net::HTTP.new.;To;;0; [o; ; [I"=For proxy-defining arguments +p_addr+ through +p_pass+, ;TI"9see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].;To;;0; [o; ; [I"$For argument +opts+, see below.;T@o; ; [I"With no block given:;T@o;; ;;[o;;0; [o; ; [I";Calls <tt>http.start</tt> with no block (see #start), ;TI"4which opens a TCP connection and \HTTP session.;To;;0; [o; ; [I"Returns +http+.;To;;0; [o; ; [I"9The caller should call #finish to close the session:;T@o:RDoc::Markup::Verbatim; [ I"&http = Net::HTTP.start(hostname) ;TI"http.started? # => true ;TI"http.finish ;TI"http.started? # => false ;T:@format0o; ; [I"With a block given:;T@o;; ;;[o;;0; [o; ; [I"BCalls <tt>http.start</tt> with the block (see #start), which:;T@o;; ;;[ o;;0; [o; ; [I".Opens a TCP connection and \HTTP session.;To;;0; [o; ; [I"Calls the block, ;TI"7which may make any number of requests to the host.;To;;0; [o; ; [I"?Closes the \HTTP session and TCP connection on block exit.;To;;0; [o; ; [I"(Returns the block's value +object+.;T@o;;0; [o; ; [I"Returns +object+.;T@o; ; [I" Example:;T@o;; [ I"/hostname = 'jsonplaceholder.typicode.com' ;TI")Net::HTTP.start(hostname) do |http| ;TI"& puts http.get('/todos/1').body ;TI"& puts http.get('/todos/2').body ;TI" end ;T;0o; ; [I"Output:;T@o;; [I"{ ;TI" "userId": 1, ;TI" "id": 1, ;TI"& "title": "delectus aut autem", ;TI" "completed": false ;TI"} ;TI"{ ;TI" "userId": 1, ;TI" "id": 2, ;TI"6 "title": "quis ut nam facilis et officia qui", ;TI" "completed": false ;TI"} ;T;0o; ; [I"BIf the last argument given is a hash, it is the +opts+ hash, ;TI":where each key is a method or accessor to be called, ;TI"*and its value is the value to be set.;T@o; ; [I"The keys may include:;T@o;; ;;[o;;0; [o; ; [I" #ca_file;To;;0; [o; ; [I" #ca_path;To;;0; [o; ; [I" #cert;To;;0; [o; ; [I"#cert_store;To;;0; [o; ; [I" #ciphers;To;;0; [o; ; [I"#close_on_empty_response;To;;0; [o; ; [I"+ipaddr+ (calls #ipaddr=);To;;0; [o; ; [I"#keep_alive_timeout;To;;0; [o; ; [I" #key;To;;0; [o; ; [I"#open_timeout;To;;0; [o; ; [I"#read_timeout;To;;0; [o; ; [I"#ssl_timeout;To;;0; [o; ; [I"#ssl_version;To;;0; [o; ; [I" +use_ssl+ (calls #use_ssl=);To;;0; [o; ; [I"#verify_callback;To;;0; [o; ; [I"#verify_depth;To;;0; [o; ; [I"#verify_mode;To;;0; [o; ; [I"#write_timeout;T@o; ; [I"MNote: If +port+ is +nil+ and <tt>opts[:use_ssl]</tt> is a truthy value, ;TI"Kthe value passed to +new+ is Net::HTTP.https_default_port, not +port+.;T: @fileI"lib/net/http.rb;T:0@omit_headings_from_table_of_contents_below0I"�HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) -> http HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) {|http| ... } -> object ;TI" http;T[ I"(address, *arg);T@�FI" HTTP;TcRDoc::NormalClass00