Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ WinHttpCrackUrl失败,错误为87_C++_Http - Fatal编程技术网

C++ WinHttpCrackUrl失败,错误为87

C++ WinHttpCrackUrl失败,错误为87,c++,http,C++,Http,此WinHttpCrackUrl api在Win7(OS)上失败,参数为87(无效)。请任何人提出解决方案,或者如何在服务器端轻松解码我的URL?此外,我想知道如何区分%20与编码URL以及URL中存在的实际数据。示例:localhost:8080\Server\search?value=“value%20”将所需的组件长度设置为预期值 如果不需要破裂,则全部归零 URL_COMPONENTS urlComp; LPCWSTR pwszUrl1 = L"http://search.msn.

此WinHttpCrackUrl api在Win7(OS)上失败,参数为87(无效)。请任何人提出解决方案,或者如何在服务器端轻松解码我的URL?此外,我想知道如何区分%20与编码URL以及URL中存在的实际数据。示例:localhost:8080\Server\search?value=“value%20”

将所需的组件长度设置为预期值

如果不需要破裂,则全部归零

URL_COMPONENTS urlComp;
LPCWSTR pwszUrl1 = 
  L"http://search.msn.com/results.asp?RS=CHECKED&FORM=MSNH&v=1&q=wininet";
DWORD dwUrlLen = 0;

// Initialize the URL_COMPONENTS structure.
ZeroMemory(&urlComp, sizeof(urlComp));
urlComp.dwStructSize = sizeof(urlComp);

// Set required component lengths to non-zero 
// so that they are cracked.
urlComp.dwSchemeLength    = (DWORD)-1;
urlComp.dwHostNameLength  = (DWORD)-1;
urlComp.dwUrlPathLength   = (DWORD)-1;
urlComp.dwExtraInfoLength = (DWORD)-1;

// Crack the URL.
if (!WinHttpCrackUrl( pwszUrl1, (DWORD)wcslen(pwszUrl1), 0, &urlComp))
{
    printf("Error %u in WinHttpCrackUrl.\n", GetLastError());
}


引用:“这个WinHttpCrackUrl api失败了”,然后这句话就停了,你需要一个解决方案。它失败的原因是什么?如果您检查官方,您将看到错误
87
error\u INVALID\u参数(“参数不正确”)。因此,函数的一个参数不正确。代码段工作正常,可能您在实际场景中有不同的(无效)参数。不,我在Windows 7的应用程序中使用相同的代码。另外,我想知道如何区分%20与编码URL以及URL中存在的实际数据。示例:\Server\search?value=“value%20”假设在此代码之前调用了
WinHttpOpen
是否公平?谢谢您的帖子!如果您能用简单的语言添加这段代码的功能(可能还有到API的链接),那就太好了
urlComp.dwSchemeLength    = (DWORD)0;
urlComp.dwHostNameLength  = (DWORD)0;
urlComp.dwUrlPathLength   = (DWORD)0;
urlComp.dwExtraInfoLength = (DWORD)0;
std::wstring urlHost;
urlHost.resize(url.size());

urlComp.dwHostNameLength = (DWORD)urlHost.size();
urlComp.lpszHostName = &urlHost[0];