Programming-Idioms

History of Idiom 183 > diff from v12 to v13

Edit summary for version 13 :
[Ruby] +DemoURL

Version 12

2020-11-21, 21:52:31

Version 13

2020-11-21, 22:22:04

Idiom #183 Make HTTP PUT request

Make a HTTP request with method PUT to URL u

Idiom #183 Make HTTP PUT request

Make a HTTP request with method PUT to URL u

Variables
u
Variables
u
Imports
require 'net/http'
Imports
require 'net/http'
Code
port = 1234
path = '/update_endpoint.json'
body = 'optional body content'
header = 'optional header'

http = Net::HTTP.new('www.exampledomain.com', port, header)
response = http.send_request('PUT', 'path', body)
Code
http = Net::HTTP.new(u)
response = http.send_request('PUT', path, body)
Comments bubble
If port is not given, the default port for http(s) is used.
Body and headers are optional.
Comments bubble
If port is not given, the default port for http(s) is used.
Body and headers are optional.
Doc URL
https://ruby-doc.org/stdlib-2.6.4/libdoc/net/http/rdoc/index.html
Doc URL
https://ruby-doc.org/stdlib-2.6.4/libdoc/net/http/rdoc/index.html
Demo URL
https://repl.it/@ProgIdioms/PriceySolidSort