From cceae6770cd66544fe0a6445801d11a7abe14440 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Sat, 15 Feb 2025 16:11:55 +0100 Subject: [PATCH] superagent: multipart requires content-type to be unset --- src/superagent.js | 2 +- src/test/superagent-test.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/superagent.js b/src/superagent.js index 1f66ea11a..446077902 100644 --- a/src/superagent.js +++ b/src/superagent.js @@ -144,7 +144,7 @@ class Request { if (!(this.fetchOptions.body instanceof FormData)) this.fetchOptions.body = new FormData(); const data = fs.readFileSync(filepath, 'utf8'); this.fetchOptions.body.append(name, new Blob([data]), path.basename(filepath)); - this.fetchOptions.headers.set('Content-Type', 'multipart/form-data'); + this.fetchOptions.headers.delete('Content-Type'); // explicitly remove it. without it boundary won't make it to the header! return this; } diff --git a/src/test/superagent-test.js b/src/test/superagent-test.js index ac79ce5be..6d08876ff 100644 --- a/src/test/superagent-test.js +++ b/src/test/superagent-test.js @@ -1,6 +1,5 @@ /* global it:false */ /* global describe:false */ -/* global before:false */ 'use strict'; @@ -22,4 +21,8 @@ describe('Superagent', function () { const [error] = await safe(superagent.get('https://cloudron.io').set('User-Agent', 'Mozilla').timeout(10*1000).redirects(0)); expect(error).to.be.ok(); }); + + it('can disable certs', async function () { + await superagent.get('https://www.cloudron.io').set('User-Agent', 'Mozilla').disableTLSCerts(); + }); });