diff options
| -rw-r--r-- | lgc/lgc.go | 26 | ||||
| -rw-r--r-- | rpm/rpm.go | 8 |
2 files changed, 33 insertions, 1 deletions
@@ -306,6 +306,9 @@ func (lgd *LoadGeneratingConnectionDownload) doDownload(ctx context.Context) { return } + // Used to disable compression + request.Header.Set("Accept-Encoding", "identity") + lgd.downloadStartTime = time.Now() lgd.lastIntervalEnd = 0 @@ -313,6 +316,13 @@ func (lgd *LoadGeneratingConnectionDownload) doDownload(ctx context.Context) { lgd.valid = false return } + + // Header.Get returns "" when not set + if get.Header.Get("Content-Encoding") != "" { + lgd.valid = false + fmt.Printf("Content-Encoding header was set (compression not allowed)") + return + } cr := &countingReader{n: &lgd.downloaded, ctx: ctx, readable: get.Body} _, _ = io.Copy(ioutil.Discard, cr) get.Body.Close() @@ -379,15 +389,29 @@ func (lgu *LoadGeneratingConnectionUpload) doUpload(ctx context.Context) bool { lgu.uploaded = 0 s := &syntheticCountingReader{n: &lgu.uploaded, ctx: ctx} var resp *http.Response = nil + var request *http.Request = nil var err error + if request, err = http.NewRequest( + "POST", + lgu.Path, + s, + ); err != nil { + lgu.valid = false + return false + } + + // Used to disable compression + request.Header.Set("Accept-Encoding", "identity") + lgu.uploadStartTime = time.Now() lgu.lastIntervalEnd = 0 - if resp, err = lgu.client.Post(lgu.Path, "application/octet-stream", s); err != nil { + if resp, err = lgu.client.Do(request); err != nil { lgu.valid = false return false } + resp.Body.Close() if debug.IsDebug(lgu.debug) { fmt.Printf("Ending a load-generating upload.\n") @@ -127,11 +127,19 @@ func Probe( return err } + // Used to disable compression + probe_req.Header.Set("Accept-Encoding", "identity") + probe_resp, err := client.Do(probe_req) if err != nil { return err } + // Header.Get returns "" when not set + if probe_resp.Header.Get("Content-Encoding") != "" { + return fmt.Errorf("Content-Encoding header was set (compression not allowed)") + } + // TODO: Make this interruptable somehow by using _ctx_. _, err = io.ReadAll(probe_resp.Body) if err != nil { |
