Logo

Programming-Idioms

  • Python
  • JS

Idiom #183 Make HTTP PUT request

Make a HTTP request with method PUT to the URL u

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

r = requests.put(u, headers=headers, data=data)
status_code, content = r.status_code, r.content
fetch(u, {
        method: "PUT",
	body: JSON.stringify(data)
})
using System.Net.Http;
new HttpClient().PutAsync(u, content);

New implementation...
< >
programming-idioms.org