【问题标题】:Request header value getting converted to upper case in Chrome请求标头值在 Chrome 中转换为大写
【发布时间】:2020-09-07 14:32:22
【问题描述】:

我正在尝试从一个简单的网页向 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"; start-Info="text/xml; charset=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"; start-Info="text/xml; charset=UTF-8"

由于我无法真正更改服务器服务,我想知道是否有办法强制 Chrome 使用小写标题值而不是转换它们。

类似帖子:

Why does Header Content-Type for POST request differ between chrome and firefox only in by "UTF-8" vs "utf-8"?

【问题讨论】:

    标签: javascript ajax google-chrome sharepoint http-post


    【解决方案1】:

    这导致了 chrome 上的亚马逊 aws 身份验证(GetFederationToken)问题,但不是 firefox 或 IE,因为它被用作签名的标头签名,我花了几个小时跟踪这个问题,希望这可以在遇到签名不匹配问题时拯救其他人

    我认为 chrome 选择大写 UTF-8 没有任何理由:

    https://www.w3.org/International/questions/qa-html-encoding-declarations

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-31
      • 2016-05-23
      • 2016-02-28
      • 1970-01-01
      相关资源
      最近更新 更多