gpt4 book ai didi

dart - HttpRequest::getRequestHeaders似乎只返回 header 的子集?

转载 作者:行者123 更新时间:2023-12-03 03:02:17 25 4
gpt4 key购买 nike

如您所见,我做了一个成功的请求。我的问题是我在下面打印的3行。

var headerList = request.getAllResponseHeaders();
print("RunTime type of Header List: ${headerList.runtimeType}");
print("Header List Count: ${headerList.length}");
print("Header List is as follows: \n$headerList");

因此,似乎要求 HttpRequest没有返回足够的信息。我希望它能返回所有 header 信息的完整字符串,k => v对的Map或数组。

好像它只获取了前64个字符。

为什么不获取所有文件?理想情况下,我正在尝试通过 request.getResponseHeader("Content-Disposition");获取“Content-Disposition” header ,但是正如您可以想象的那样,给定此信息,由于请求无法找到该信息,因此它实际上将返回null。

enter image description here

最佳答案

我想你需要补充
Access-Control-Expose-Headers Content-Disposition
在您的服务器上。

Access-Control-Expose-Headers (optional) - The XMLHttpRequest 2 object has a getResponseHeader() method that returns the value of a particular response header. During a CORS request, the getResponseHeader() method can only access simple response headers. Simple response headers are defined as follows:

  • Cache-Control
  • Content-Language
  • Content-Type
  • Expires
  • Last-Modified
  • Pragma

If you want clients to be able to access other headers, you have to use the Access-Control-Expose-Headers header. The value of this header is a comma-delimited list of response headers you want to expose to the client.



http://www.html5rocks.com/en/tutorials/cors/

关于dart - HttpRequest::getRequestHeaders似乎只返回 header 的子集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38962954/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com