~xenrox/faceit_checker

fd62ce598f82c3cf2167c8f42c86979c0d7a0ca4 — Thorben Günther 1 year, 1 month ago 2ab73ec
Disable HTTP/2

The Faceit API does not currently work with HTTP/2 because of some
Cloudflare Shenanigans. It returns HTML with an error code of 403
instead of the expected json body.
Disable HTTP/2 support, until the open API gets fixed.
1 files changed, 7 insertions(+), 1 deletions(-)

M faceit.go
M faceit.go => faceit.go +7 -1
@@ 2,6 2,7 @@
package main

import (
	"crypto/tls"
	"embed"
	"encoding/json"
	"encoding/xml"


@@ 111,7 112,12 @@ func main() {
		logger.Fatal("could not read templates: %v", err)
	}

	client := &http.Client{Timeout: time.Second * 3}
	// TODO: Remove
	// NOTE: Disable HTTP/2
	// Programs that must disable HTTP/2 can do so by setting Transport.TLSNextProto (for clients) to a non-nil, empty map.
	// https://godocs.io/net/http
	transport := http.Transport{TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper)}
	client := &http.Client{Timeout: time.Second * 3, Transport: &transport}

	fc := &faceitChecker{logger: logger, bearerToken: bearerToken,
		templates: tmpls, client: client}