(request, senderUrl)
| 29 | } |
| 30 | |
| 31 | async function buildOptions(request, senderUrl) { |
| 32 | if (!request.req) { |
| 33 | return request.options; |
| 34 | } |
| 35 | const contentType = request.req.data.contentType; |
| 36 | if (contentType !== "multipart/form-data") { |
| 37 | return request.options; |
| 38 | } |
| 39 | const options = { ...request.options }; |
| 40 | const body = await buildFormDataBody(request.req.data.formDataBody, senderUrl); |
| 41 | options.body = body; |
| 42 | // NOTE: we need to delete the content type header because the browser will automatically set it |
| 43 | // with the correct boundary |
| 44 | if (options.headers) { |
| 45 | for (let key in options.headers) { |
| 46 | if (key.toLowerCase() === "content-type") { |
| 47 | delete options.headers[key]; |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | return options; |
| 52 | } |
| 53 | |
| 54 | async function buildFormDataBody(body, senderUrl) { |
| 55 | let host = senderUrl.split("/#/")[0]; |
no test coverage detected