Skip to content

Commit

Permalink
http-client: fix response headers logging, provide default logger
Browse files Browse the repository at this point in the history
  • Loading branch information
eldargab committed Jun 11, 2023
1 parent a2d05de commit bfc5c4b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 15 additions & 0 deletions common/changes/@subsquid/http-client/master_2023-06-11-15-44.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"changes": [
{
"packageName": "@subsquid/http-client",
"comment": "use default logger when no logger is passed",
"type": "minor"
},
{
"packageName": "@subsquid/http-client",
"comment": "fix response headers logging",
"type": "patch"
}
],
"packageName": "@subsquid/http-client"
}
7 changes: 4 additions & 3 deletions util/http-client/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {Logger} from '@subsquid/logger'
import {createLogger} from '@subsquid/logger'
import {addErrorContext, ensureError, wait} from '@subsquid/util-internal'
import type {Headers, RequestInit, Response} from 'node-fetch'
import {AgentProvider, defaultAgentProvider} from './agent'
Expand All @@ -19,7 +20,7 @@ export interface HttpClientOptions {
httpTimeout?: number
retryAttempts?: number
retrySchedule?: number[]
log?: Logger
log?: Logger | null
}


Expand Down Expand Up @@ -60,7 +61,7 @@ export class HttpClient {
private requestCounter = 0

constructor(options: HttpClientOptions = {}) {
this.log = options.log
this.log = options.log === null ? undefined : options.log || createLogger('sqd:http-client')
this.headers = options.headers
this.setBaseUrl(options.baseUrl)
this.agent = options.agent || defaultAgentProvider
Expand Down Expand Up @@ -149,7 +150,7 @@ export class HttpClient {
httpRequestId: req.id,
httpResponseUrl: url,
httpResponseStatus: status,
httpResponseHeaders: headers
httpResponseHeaders: Array.from(headers)
}, 'http headers')
}
}
Expand Down

0 comments on commit bfc5c4b

Please sign in to comment.