You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: pull_session_tracker.go
    path of file: ./repos/benthos/internal/cli/studio
    
    the code of the file until where you have to start completion: package studio

import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/fs"
	"net/http"
	"net/url"
	"path"
	"strconv"
	"sync"
	"time"

	"github.com/benthosdev/benthos/v4/in
    
func (s *sessionTracker) doRateLimitedReq(ctx context.Context, reqFn func() (*http.Request, error)) (res *http.Response, err error) {
	for {
		if err = s.waitForRateLimit(ctx); err != nil {
			return
		}

		var req *http.Request
		if req, err = reqFn(); err != nil {
			return
		}

		// Wait for one second after an error by default
		nextWait := s.nowFn().Add(time.Second)
		var abortReq bool
		if res, err = http.DefaultClient.Do(req.WithContext(ctx)); err == nil {
			// No request error, but also check the response status and rate
			// limit suggestions.
			var nextWaitTmp *time.Time
			if nextWaitTmp, abortReq, err = s.checkResponse(res); nextWaitTmp != nil {
				// The response has suggested a time to wait for, so we use
				// that instead of our default.
				nextWait = *nextWaitTmp
			}
		}
		if err == nil || abortReq {
			return
		}
		if ctxErr := ctx.Err(); ctxErr != nil {
			err = ctxErr
			return
		}

		errFields := map[string]string{
			"host":  req.URL.Host,
			"path":  req.URL.Path,
			"error": err.Error(),
		}
		if res != nil {
			errFields["status"] = res.Status
		}
		s.logger.WithFields(errFields).Error("Studio request failed")

		s.mut.Lock()
		s.rateLimitTo = &nextWait
		s.mut.Unlock()
	}
}