@@ -40,6 +40,7 @@ func NewCloudIPCStreamIterator(
4040 startRowOffset : startRowOffset ,
4141 pendingLinks : NewQueue [cli_service.TSparkArrowResultLink ](),
4242 downloadTasks : NewQueue [cloudFetchDownloadTask ](),
43+ httpClient : cfg .UserConfig .CloudFetchConfig .HTTPClient ,
4344 }
4445
4546 for _ , link := range files {
@@ -140,6 +141,7 @@ type cloudIPCStreamIterator struct {
140141 startRowOffset int64
141142 pendingLinks Queue [cli_service.TSparkArrowResultLink ]
142143 downloadTasks Queue [cloudFetchDownloadTask ]
144+ httpClient * http.Client
143145}
144146
145147var _ IPCStreamIterator = (* cloudIPCStreamIterator )(nil )
@@ -162,6 +164,7 @@ func (bi *cloudIPCStreamIterator) Next() (io.Reader, error) {
162164 resultChan : make (chan cloudFetchDownloadTaskResult ),
163165 minTimeToExpiry : bi .cfg .MinTimeToExpiry ,
164166 speedThresholdMbps : bi .cfg .CloudFetchSpeedThresholdMbps ,
167+ httpClient : bi .httpClient ,
165168 }
166169 task .Run ()
167170 bi .downloadTasks .Enqueue (task )
@@ -210,6 +213,7 @@ type cloudFetchDownloadTask struct {
210213 link * cli_service.TSparkArrowResultLink
211214 resultChan chan cloudFetchDownloadTaskResult
212215 speedThresholdMbps float64
216+ httpClient * http.Client
213217}
214218
215219func (cft * cloudFetchDownloadTask ) GetResult () (io.Reader , error ) {
@@ -252,7 +256,7 @@ func (cft *cloudFetchDownloadTask) Run() {
252256 cft .link .StartRowOffset ,
253257 cft .link .RowCount ,
254258 )
255- data , err := fetchBatchBytes (cft .ctx , cft .link , cft .minTimeToExpiry , cft .speedThresholdMbps )
259+ data , err := fetchBatchBytes (cft .ctx , cft .link , cft .minTimeToExpiry , cft .speedThresholdMbps , cft . httpClient )
256260 if err != nil {
257261 cft .resultChan <- cloudFetchDownloadTaskResult {data : nil , err : err }
258262 return
@@ -300,6 +304,7 @@ func fetchBatchBytes(
300304 link * cli_service.TSparkArrowResultLink ,
301305 minTimeToExpiry time.Duration ,
302306 speedThresholdMbps float64 ,
307+ httpClient * http.Client ,
303308) (io.ReadCloser , error ) {
304309 if isLinkExpired (link .ExpiryTime , minTimeToExpiry ) {
305310 return nil , errors .New (dbsqlerr .ErrLinkExpired )
@@ -317,9 +322,12 @@ func fetchBatchBytes(
317322 }
318323 }
319324
325+ if httpClient == nil {
326+ httpClient = http .DefaultClient
327+ }
328+
320329 startTime := time .Now ()
321- client := http .DefaultClient
322- res , err := client .Do (req )
330+ res , err := httpClient .Do (req )
323331 if err != nil {
324332 return nil , err
325333 }
0 commit comments