MCPcopy Create free account
hub / github.com/aixed/WeChat-Hook / HttpPostThread

Function HttpPostThread

src/http_post.cpp:15–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13};
14
15static DWORD WINAPI HttpPostThread(LPVOID lp)
16{
17 HttpPostTask* task = (HttpPostTask*)lp;
18 if (!task)
19 return 0;
20
21 // ===== URL 解析 =====
22 URL_COMPONENTSW uc{};
23 uc.dwStructSize = sizeof(uc);
24
25 wchar_t host[256] = {};
26 wchar_t path[1024] = {};
27
28 uc.lpszHostName = host;
29 uc.dwHostNameLength = _countof(host);
30 uc.lpszUrlPath = path;
31 uc.dwUrlPathLength = _countof(path);
32
33 if (!WinHttpCrackUrl(task->url.c_str(), 0, 0, &uc))
34 return 0;
35
36 // ===== Session =====
37 HINTERNET hSession = WinHttpOpen(
38 L"HTTP/1.1",
39 WINHTTP_ACCESS_TYPE_NO_PROXY,
40 WINHTTP_NO_PROXY_NAME,
41 WINHTTP_NO_PROXY_BYPASS,
42 0
43 );
44 if (!hSession)
45 return 0;
46
47 // ===== Connect =====
48 HINTERNET hConnect = WinHttpConnect(
49 hSession,
50 uc.lpszHostName,
51 uc.nPort,
52 0
53 );
54 if (!hConnect)
55 {
56 WinHttpCloseHandle(hSession);
57 return 0;
58 }
59
60 DWORD flags = (uc.nScheme == INTERNET_SCHEME_HTTPS)
61 ? WINHTTP_FLAG_SECURE
62 : 0;
63
64 // ===== Request =====
65 HINTERNET hRequest = WinHttpOpenRequest(
66 hConnect,
67 L"POST",
68 uc.lpszUrlPath,
69 nullptr,
70 WINHTTP_NO_REFERER,
71 WINHTTP_DEFAULT_ACCEPT_TYPES,
72 flags

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected