Archive for April, 2019

Support #HTTP2 in your C# Client code


If you use code such as WebClient to make HTTP requests from C#, then you’re probably using HTTP 1.1. if you want to use HTTP/2 then you need to write some extra code.

First, let’s prove that you’re using HTTP 1.1

WebClient wc = new WebClient();
var check1 = wc.DownloadString(“”);

and the response is


Now, to use HTTP 2, you need to override a setting here;

public class Http2CustomHandler : WinHttpHandler
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
request.Version = new Version(“2.0”);
return base.SendAsync(request, cancellationToken);

And we can make a GET request like so;

public static string GetHtmlFromUrl(string Url)
var httpClient = new HttpClient(new Http2CustomHandler { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate });
var resTask = httpClient.GetAsync(new Uri(Url));
var response = resTask.Result;
var strTask = response.Content.ReadAsStringAsync();
var strResponse = strTask.Result;
return strResponse;

And check again;

var check2 = GetHtmlFromUrl(“;);

Which yields


Hope this helps!




Categories: Uncategorized now supports #BCC in #Javascript #Email

smtpjs is a Javascript library for sending email from client-side Javascript (not node), it offers plenty of features for sending email, but one was missing until this morning, the ability to send BCC emails. (Blind Carbon-Copy)

It’s used just like the “To” field as follows

            SecureToken : “…..”,
            To : [““, ““] ,
            Bcc : [““, ““],
If Bcc is sent as an array, it can send to multiple addresses, or can be just a string, if you just want to send to one BCC.
Happy mailing …
Categories: Uncategorized

Temporary failure in name resolution #Fix #Linux #PHP


If you get this error message in PHP,

php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution

Then you are either calling a domain name that doesn’t exist, or your DNS resolution has failed on your server. Assuming you haven’t mistyped the API url, then you can check for a DNS issue by SSH’ing into your server and trying to ping and see if you get a response. – If that fails, then you need to fix your resolving DNS servers, and perhaps contact your host company too.

Google offer their own DNS resolving servers for free, and you can use them as follows;

sudo echo nameserver > /etc/resolv.conf
sudo /etc/init.d/httpd restart

Which changes the DNS resolver on your server to Google’s server with IP, and then restarts your web server. You may use apache2 here instead of httpd – depending on your flavour of linux.


Categories: Uncategorized