Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Php

Idiom #183 Make HTTP PUT request

Make a HTTP request with method PUT to the URL u

require ext-curl
<?php

$url = 'http://localhost/tester/log.php';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$fields = array("id" => 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
$response = curl_exec($ch);

echo $response;
using System.Net.Http;
new HttpClient().PutAsync(u, content);

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