Write value to a registry value named name.
The value type is REG_SZ(write_s
), REG_DWORD(write_i
), or REG_BINARY(write_bin
).
Same as IO
.
Same as IO
.
Same as IO
.
Returns true
if stat is writable by the effective user id of this process.
File.stat("testfile").writable? #=> true
Returns true
if the operating system supports pipes and stat is a pipe; false
otherwise.
Returns true
if stat has its sticky bit set, false
if it doesn’t or if the operating system doesn’t support this feature.
File.stat("testfile").sticky? #=> false
Transfers ownership to a new buffer, deallocating the current one.
buffer = IO::Buffer.new('test') other = buffer.transfer other # => # #<IO::Buffer 0x00007f136a15f7b0+4 SLICE> # 0x00000000 74 65 73 74 test buffer # => # #<IO::Buffer 0x0000000000000000+0 NULL> buffer.null? # => true
Get the URI
of the remote object.
Get the URI
of the remote object.
Posts data to the specified URI
object.
Example:
require 'net/http' require 'uri' Net::HTTP.post URI('http://www.example.com/api/search'), { "q" => "ruby", "max" => "50" }.to_json, "Content-Type" => "application/json"
Creates a new Net::HTTP
object, then additionally opens the TCP connection and HTTP
session.
Arguments are the following:
hostname or IP address of the server
port of the server
address of proxy
port of proxy
user of proxy
pass of proxy
optional hash
opt sets following values by its accessor. The keys are ipaddr, ca_file
, ca_path
, cert, cert_store
, ciphers, keep_alive_timeout
, close_on_empty_response
, key, open_timeout
, read_timeout
, write_timeout
, ssl_timeout
, ssl_version
, use_ssl, verify_callback
, verify_depth
and verify_mode. If you set :use_ssl as true, you can use https and default value of verify_mode
is set as OpenSSL::SSL::VERIFY_PEER.
If the optional block is given, the newly created Net::HTTP
object is passed to it and closed when the block finishes. In this case, the return value of this method is the return value of the block. If no block is given, the return value of this method is the newly created Net::HTTP
object itself, and the caller is responsible for closing it upon completion using the finish() method.
The IP address to connect to/used to connect to
Set
the IP address to connect to
Returns true if the HTTP
session has been started.
Opens a TCP connection and HTTP
session.
When this method is called with a block, it passes the Net::HTTP
object to the block, and closes the TCP connection and HTTP
session after the block has been executed.
When called with a block, it returns the return value of the block; otherwise, it returns self.
Posts data
(must be a String
) to path
. header
must be a Hash
like { ‘Accept’ => ‘/’, … }.
This method returns a Net::HTTPResponse
object.
If called with a block, yields each fragment of the entity body in turn as a string as it is read from the socket. Note that in this case, the returned response object will not contain a (meaningful) body.
dest
argument is obsolete. It still works but you must not use it.
This method never raises exception.
response = http.post('/cgi-bin/search.rb', 'query=foo') # using block File.open('result.txt', 'w') {|f| http.post('/cgi-bin/search.rb', 'query=foo') do |str| f.write str end }
You should set Content-Type: header field for POST. If no Content-Type: field given, this method uses “application/x-www-form-urlencoded” by default.
Sends a TRACE request to the path
and gets a response, as an HTTPResponse
object.
Sends an HTTPRequest
object req
to the HTTP
server.
If req
is a Net::HTTP::Post
or Net::HTTP::Put
request containing data, the data is also sent. Providing data for a Net::HTTP::Head
or Net::HTTP::Get
request results in an ArgumentError
.
Returns an HTTPResponse
object.
When called with a block, passes an HTTPResponse
object to the block. The body of the response will not have been read yet; the block can process it using HTTPResponse#read_body
, if desired.
This method never raises Net::* exceptions.