6

I have setup a Cloudflare Service Worker that echos the HTTP and TLS version used to connect.

Service Worker code:

addEventListener('fetch', event => 
  event.respondWith(
    new Response(
      event.request.cf.httpProtocol + " " +
      event.request.cf.tlsVersion,

      {status: 200}
    )
  )
);

Then, I made a GET request using the anonymous execution window.

HttpRequest request = new HttpRequest();
request.setEndpoint('https://echoecho.mpg.workers.dev/');
request.setMethod('GET');

Http http = new Http();
HttpResponse response = http.send(request);

System.debug(response.getBody());

This produces the output: HTTP/1.1 TLSv1.2.

The only reference to HTTP/2 that I could find was not very helpful.

Is there any way to force Salesforce to use the HTTP/2 protocol instead of HTTP/1.1?

6

2 Answers 2

2

The Apex language does not give you any control over what protocol is used when making callouts. The Http class has methods only for send() and toString(), with the former accepting no overloads which would allow you to configure behavior. The HttpRequest class has numerous setter methods, but none of them would allow you to specify protocol either.

2
  • I do not WANT to specify the protocol, I just want to know if Salesforce will connect to a server that only supports HTTP/2? Commented Apr 13, 2020 at 16:53
  • If you visit the service worker from your browser, you will see something like HTTP/2 TLSv1.3. This is because all modern browsers will use HTTP/2 if the server supports it, and fallback to HTTP/1.1 otherwise. As you can see from my testing, Salesforce used the HTTP/1.1 protocol even though Cloudflare supports HTTP/2. Does Salesforce support the HTTP/2 protocol for outgoing requests? Commented Apr 13, 2020 at 16:56
2

From the developer forums:

Salesforce does not support HTTP/2 protocol currently.

Related link: https://success.salesforce.com/ideaView?id=0873A0000015DEtQAM

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .