javascript - 请求标头值在 Chrome 中转换为大写
问题描述
我正在尝试从一个简单的网页向 SharePoint 服务器发布一个 http 帖子。此请求已在 Internet Explorer 上运行,但在 Chrome 上失败。
$.ajax({
url:"http://redacted/_vti_bin/cellstorage.svc/CellStorageService",
type:'POST',
headers:{
'MIME-Version': "1.0",
'SOAPAction': "http://schemas.microsoft.com/sharepoint/soap/ICellStorages/ExecuteCellStorageRequest",
'Content-Type': "multipart/related; type=\"application/xop+xml\"; boundary=\"urn:uuid:8cfcbb22-dd52-4889-b29d-9ff2dcf909b2\"; start=\"<f13ad06d-8530-4af1-8cf3-d6d75c1635d4@tempuri.org>\"; start-Info=\"text/xml; charset=utf-8\"",
'X-Vermeer-Content-Type': "application/x-www-form-urlencoded"
},
我的测试表明,除非请求标头大小写保持不变,否则我正在联系的 Web 服务 (/_vti_bin/cellstorage.svc/CellStorageService) 将失败:
内容类型:多部分/相关;类型=“应用程序/xop+xml”;边界="urn:uuid:8cfcbb22-dd52-4889-b29d-9ff2dcf909b2"; start="f13ad06d-8530-4af1-8cf3-d6d75c1635d4@tempuri.org"; 开始信息=“文本/xml;字符集=utf-8 ”
但是,Chrome 似乎会自动将请求头值从“utf-8”转换为“UTF-8”,这可以通过 fiddler 输出来确认。这会导致错误:
POST http://redacted/_vti_bin/cellstorage.svc/CellStorageService 400(错误请求)
内容类型:多部分/相关;类型=“应用程序/xop+xml”;边界="urn:uuid:8cfcbb22-dd52-4889-b29d-9ff2dcf909b2"; start="f13ad06d-8530-4af1-8cf3-d6d75c1635d4@tempuri.org"; 开始信息=“文本/xml;字符集=UTF-8 ”
由于我无法真正更改服务器服务,我想知道是否有办法强制 Chrome 使用小写标题值而不是转换它们。
类似帖子:
为什么 POST 请求的 Header Content-Type 在 chrome 和 firefox 之间仅在“UTF-8”和“utf-8”方面有所不同?
解决方案
这导致了 chrome 上的亚马逊 aws 身份验证(GetFederationToken)问题,但不是 firefox 或 IE,因为它被用作签名的标头签名,我花了几个小时跟踪这个问题,希望这可以在遇到签名不匹配问题时拯救其他人
我认为 chrome 选择大写 UTF-8 没有任何理由:
https://www.w3.org/International/questions/qa-html-encoding-declarations
推荐阅读
- asp.net - ASP.NET Core 中的异步延续在哪里排队?
- sql - 聚合和团体预订
- powershell - LastWriteTime 未排序为 DateTime
- r - r:使用 lm 和 ggplot2 生成拟合图与实际图
- c# - 调用目标(MethodBase.Invoke 方法)抛出了错误异常
- java - 需要我的二维数组来打印,但它只在输出框中显示一个点
- php - 如何获取 ajax 响应值/字符串并在 if 条件下使用它?
- javascript - 在给定级别汇总树(嵌套对象)
- java - 间歇性 Jackson 模型映射器参考链错误
- for-loop - 访问 VBA 嵌套 for 循环仅适用于第一条记录