@@ -78,6 +78,9 @@ export default class Spark {
78
78
stats . providerAddress = provider . address
79
79
80
80
await this . fetchCAR ( provider . protocol , provider . address , retrieval . cid , stats )
81
+ if ( stats . protocol === 'http' ) {
82
+ await this . testHeadRequest ( provider . address , retrieval . cid , stats )
83
+ }
81
84
}
82
85
83
86
async fetchCAR ( protocol , address , cid , stats ) {
@@ -160,6 +163,22 @@ export default class Spark {
160
163
stats . endAt = new Date ( )
161
164
}
162
165
166
+ async testHeadRequest ( address , cid , stats ) {
167
+ const url = getRetrievalUrl ( 'http' , address , cid )
168
+ console . log ( `Testing HEAD request: ${ url } ` )
169
+ try {
170
+ const res = await this . #fetch( url , {
171
+ method : 'HEAD' ,
172
+ signal : AbortSignal . timeout ( 10_000 )
173
+ } )
174
+ stats . headStatusCode = res . status
175
+ } catch ( err ) {
176
+ console . error ( `Failed to make HEAD request to ${ address } for ${ cid } ` )
177
+ console . error ( err )
178
+ stats . headStatusCode = mapErrorToStatusCode ( err )
179
+ }
180
+ }
181
+
163
182
async submitMeasurement ( task , stats ) {
164
183
console . log ( 'Submitting measurement...' )
165
184
const payload = {
@@ -211,11 +230,11 @@ export default class Spark {
211
230
this . handleRunError ( err )
212
231
}
213
232
const duration = Date . now ( ) - started
214
- const delay = calculateDelayBeforeNextTask ( {
233
+ const delay = /* calculateDelayBeforeNextTask({
215
234
roundLengthInMs: APPROX_ROUND_LENGTH_IN_MS,
216
235
maxTasksPerRound: this.#tasker.maxTasksPerRound,
217
236
lastTaskDurationInMs: duration
218
- } )
237
+ }) */ 0
219
238
220
239
if ( delay > 0 ) {
221
240
console . log (
@@ -263,7 +282,8 @@ export function newStats () {
263
282
carTooLarge : false ,
264
283
byteLength : 0 ,
265
284
carChecksum : null ,
266
- statusCode : null
285
+ statusCode : null ,
286
+ headStatusCode : null
267
287
}
268
288
}
269
289
0 commit comments