File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -220,12 +220,13 @@ class Replicate {
220
220
url . searchParams . append ( key , value ) ;
221
221
}
222
222
223
- const headers = { } ;
223
+ const headers = {
224
+ "Content-Type" : "application/json" ,
225
+ "User-Agent" : userAgent ,
226
+ } ;
224
227
if ( auth ) {
225
228
headers [ "Authorization" ] = `Bearer ${ auth } ` ;
226
229
}
227
- headers [ "Content-Type" ] = "application/json" ;
228
- headers [ "User-Agent" ] = userAgent ;
229
230
if ( options . headers ) {
230
231
for ( const [ key , value ] of Object . entries ( options . headers ) ) {
231
232
headers [ key ] = value ;
@@ -235,6 +236,8 @@ class Replicate {
235
236
let body = undefined ;
236
237
if ( data instanceof FormData ) {
237
238
body = data ;
239
+ // biome-ignore lint/performance/noDelete:
240
+ delete headers [ "Content-Type" ] ; // Use automatic content type header
238
241
} else if ( data ) {
239
242
body = JSON . stringify ( data ) ;
240
243
}
Original file line number Diff line number Diff line change @@ -296,7 +296,6 @@ describe("Replicate client", () => {
296
296
297
297
nock ( BASE_URL )
298
298
. post ( "/files" )
299
- . matchHeader ( "Content-Type" , "multipart/form-data" )
300
299
. reply ( 201 , {
301
300
urls : {
302
301
get : "https://replicate.com/api/files/123" ,
@@ -317,17 +316,14 @@ describe("Replicate client", () => {
317
316
prompt : "Tell me a story" ,
318
317
data,
319
318
} ,
320
- stream : true ,
321
319
} ) ;
322
320
323
321
expect ( client . fetch ) . toHaveBeenCalledWith (
324
322
new URL ( "https://api.replicate.com/v1/files" ) ,
325
323
{
326
324
method : "POST" ,
327
325
body : expect . any ( FormData ) ,
328
- headers : expect . objectContaining ( {
329
- "Content-Type" : "multipart/form-data" ,
330
- } ) ,
326
+ headers : expect . any ( Object ) ,
331
327
}
332
328
) ;
333
329
const form = mockedFetch . mock . calls [ 0 ] [ 1 ] ?. body as FormData ;
You can’t perform that action at this time.
0 commit comments