/
githubmirror
/
axios
Обзор
Документация
Войти
/
githubmirror
/
axios
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v1.x
lib/core/setFormDataHeaders.js
27 строк
907 B
QodeXcli
refactor(helpers): extract duplicated setFormDataHeaders into a shared helper (#11062)
15 июл 2026, 20:59
Не верифицирован
15 июл 2026, 20:59
58b16c8
Код
Авторство
О чём код?
'use strict'; const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length']; /** * Apply the headers generated by a FormData implementation to the request headers, * honoring the `formDataHeaderPolicy` option: with 'content-only', copy only the * content-* headers; otherwise merge all of them. * * @param {AxiosHeaders} headers - the request headers to mutate * @param {Object | null | undefined} formHeaders - headers produced by the FormData implementation * @param {String} [policy] - the resolved `formDataHeaderPolicy` config value * * @returns {void} */ export default function setFormDataHeaders(headers, formHeaders, policy) { if (policy !== 'content-only') { headers.set(formHeaders); return; } Object.entries(formHeaders || {}).forEach(([key, val]) => { if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) { headers.set(key, val); } }); }