Sha256: 75af7c5ef49df40bd73e9ac260b98a942bea234d6d409f21c189ebeae2418c7c

Contents?: true

Size: 799 Bytes

Versions: 2

Compression:

Stored size: 799 Bytes

Contents

Examples here assume that <tt>net/http</tt> has been required
(which also requires +uri+):

  require 'net/http'

Many code examples here use these example websites:

- https://jsonplaceholder.typicode.com.
- http://example.com.

Some examples also assume these variables:

  uri = URI('https://jsonplaceholder.typicode.com')
  uri.freeze # Examples may not modify.
  hostname = uri.hostname # => "jsonplaceholder.typicode.com"
  port = uri.port         # => 443

So that example requests may be written as:

  Net::HTTP.get(uri)
  Net::HTTP.get(hostname, '/index.html')
  Net::HTTP.start(hostname) do |http|
    http.get('/todos/1')
    http.get('/todos/2')
  end

An example that needs a modified URI first duplicates +uri+, then modifies the duplicate:

  _uri = uri.dup
  _uri.path = '/todos/1'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
net-http-0.3.2 doc/net-http/examples.rdoc
net-http-0.3.1 doc/net-http/examples.rdoc