Programming-Idioms

Implementation
PHP

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Implementation edit is for fixing errors and enhancing with metadata.

Instead of changing the code of the snippet, consider creating another PHP implementation.

Other implementations
import "net/http"
req, err := http.NewRequest("PUT", u, body)
if err != nil {
	return err
}
req.Header.Set("Content-Type", contentType)
req.ContentLength = contentLength
response, err := http.DefaultClient.Do(req)
fphttpclient
with TFPHTTPClient.Create(nil) do
begin
 Put(u);
 Free;
end;
require 'net/http'
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)
fetch(u, {
        method: "PUT",
	body: JSON.stringify(data)
})
requests
import requests

content_type = 'text/plain'
headers = {'Content-Type': content_type}
data = {}

r = requests.put(url, headers=headers, data=data)
status_code, content = r.status_code, r.content
using System.Net.Http;
new HttpClient().PutAsync(u, content);
use HTTP::Tiny qw();
my $response = HTTP::Tiny->new->put($u, {content => $http_request_body});