【问题标题】:Determine the name of a file to download确定要下载的文件的名称
【发布时间】:2011-09-06 03:05:49
【问题描述】:

我需要从格式类似于http://server.com/settings/files/1 的网址下载文件,当我将此网址粘贴到网络浏览器中时,这可以确定在这种情况下要下载的文件的名称scheme_563.txt,我的问题是如何使用 wininet 函数检索要下载的文件名(显然不包含在 url 中)?目前我正在使用具有多个值的HttpQueryInfo 函数,例如 HTTP_QUERY_CONTENT_LOCATION、HTTP_QUERY_CONTENT_DESCRIPTION 等,但没有运气。

【问题讨论】:

    标签: delphi http wininet


    【解决方案1】:

    根据http://en.wikipedia.org/wiki/List_of_HTTP_header_fieldsContent-Disposition header 包含此信息

    Content-Disposition: attachment; filename=fname.ext
    

    在这种情况下,对于 HTTP GET 或 HEAD 请求的响应中可能会提供此可选标头。

    请注意,文件名可能已编码 - 请参阅 How to encode the filename parameter of Content-Disposition header in HTTP? 进行讨论

    【讨论】:

      猜你喜欢
      • 2021-12-15
      • 1970-01-01
      • 2019-02-24
      • 1970-01-01
      • 1970-01-01
      • 2010-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多