URLDownloadToFile 失败,0x800c0008 (INET

编程入门 行业动态 更新时间:2024-10-26 08:33:01
本文介绍了URLDownloadToFile 失败,0x800c0008 (INET_E_DOWNLOAD_FAILURE) 取决于 URL 的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我知道

有没有办法使用 URLDownloadToFile 下载长度超过 2084 个字符的 URL?

解决方案

WinInet 的 INTERNET_MAX_URL_LENGTH 常量正好是 2084,包括一个空终止符.

另请参阅您可以传递给 Wininet 函数 HttpOpenRequest 的最大 URL 长度是多少? 的其他各种问题的答案与网址相关的限制.

如果您需要下载更长的 URL,则必须使用另一个 HTTP 客户端库.

I'm aware there is a similar question here. However my symptoms differ. There seems to be some kind of URL length restriction in place that I couldn't find documented. The limit seens to be 2084 (sic! not 2048!) characters in the URL. The easiest repro is just a console application with this code:

#include "stdafx.h"
#include "urlmon.h"
#pragma comment(lib, "urlmon")


int main()
{
    HRESULT hr = URLDownloadToFile(NULL,L"http://www.google.de/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png?oids=1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890",
        L"c:\\temp\\x.png",
        0,
        NULL);

    return 0;
}

Of course, the URL doesn't make actual sense, in my real life example these are important parameters. As soon as I shorten the URL below 2084 characters, I get back S_OK and everything is fine.

I used Fiddler to check the request which tells me I'm seeing http status code 200 (OK) for the download and even the server response is just perfect:

Is there any way to download URLs longer than 2084 characters using URLDownloadToFile?

解决方案

WinInet's INTERNET_MAX_URL_LENGTH constant is exactly 2084, including a null terminator.

Also see the answers to What is the maximum URL length you can pass to the Wininet function, HttpOpenRequest? for various other URL-related limits.

If you need to download a longer URL, you will have to use another HTTP client library.

这篇关于URLDownloadToFile 失败,0x800c0008 (INET_E_DOWNLOAD_FAILURE) 取决于 URL 的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-26 00:19:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1126818.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:URLDownloadToFile   INET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!