通过获取请求发送自定义 headers 时忽略 ReactNative 区分大小写

ReactNative case sensitivity ignored when sending custom headers through fetch request

我在 Mac 上使用 React Native 0.23.1(也尝试使用 29)。在获取请求反应 ios 期间,当我发送自定义 header (例如 'Api-Version' : '0.1' )时,服务器以小写形式接收它('api-version':'0.1 '). 编写 header 的标准是使用驼峰式大小写,我无法控制服务器代码,因此请求失败,因为它期望 header 中的 camelcase.When 检查服务器日志发现所有其他非自定义 header 都是驼峰式大小写,而只有自定义 header 是全小写。

我尝试使用不同的 http 客户端,例如 frisbee 和 axios 仍然是一样的。

使用 chrome 控制台执行相同的请求成功。

以下是我的获取代码

  fetch(Properties.uris.base + Properties.uris.getBusinessDetails.replace("{businessId}",   Properties.appId).replace("{timezone",this.getTimeZone()), {
        method: "GET",
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
            'User-Agent': DeviceInfo.getUserAgent(),
            'X-UserId':userDetailsJson.username,
            'X-BusinessId':Properties.appId,
            'X-App-Version': DeviceInfo.getVersion(),
            'Api-Version': Properties.fetchHeaderInformation.apiVersion,
        }})
        .then((response) => response.json())

我不得不从 github 中分叉 fetch repo 并进行更改,然后在 React Native 项目中使用它