From 3c59340e315d860f1c39d3d41e808770d0b91697 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Mon, 12 Dec 2022 10:02:04 -0500 Subject: [Feature] Add support for test_endpoint When a test_endpoint is returned in the config for a test, all requests will be sent to that host but the :authority pseudo header (nee: Host: message header) will contain the host specified in the various `_url` fields of the config data. --- lgc/lgc.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lgc') diff --git a/lgc/lgc.go b/lgc/lgc.go index bb39a31..bbab5ad 100644 --- a/lgc/lgc.go +++ b/lgc/lgc.go @@ -57,6 +57,7 @@ type LoadGeneratingConnectionDownload struct { downloaded uint64 lastIntervalEnd int64 Path string + Host string downloadStartTime time.Time lastDownloaded uint64 client *http.Client @@ -316,6 +317,17 @@ func (lgd *LoadGeneratingConnectionDownload) doDownload(ctx context.Context) { return } + // To support test_endpoint + if len(lgd.Host) != 0 { + if debug.IsDebug(lgd.debug) { + fmt.Printf( + "Because of a test_endpoint in the config, there is a special Host set for this connection: %s\n", + lgd.Host, + ) + } + request.Host = lgd.Host + } + // Used to disable compression request.Header.Set("Accept-Encoding", "identity") @@ -347,6 +359,7 @@ type LoadGeneratingConnectionUpload struct { uploaded uint64 lastIntervalEnd int64 Path string + Host string uploadStartTime time.Time lastUploaded uint64 client *http.Client @@ -411,6 +424,17 @@ func (lgu *LoadGeneratingConnectionUpload) doUpload(ctx context.Context) bool { return false } + // To support test_endpoint + if len(lgu.Host) != 0 { + if debug.IsDebug(lgu.debug) { + fmt.Printf( + "Because of a test_endpoint in the config, there is a special Host set for this connection: %s\n", + lgu.Host, + ) + } + request.Host = lgu.Host + } + // Used to disable compression request.Header.Set("Accept-Encoding", "identity") -- cgit v1.2.3