Textractor_test/extensions/network.h

33 lines
799 B
C
Raw Normal View History

2019-02-11 10:46:39 +08:00
#pragma once
2019-06-13 16:01:29 +08:00
#include "common.h"
2019-02-11 10:46:39 +08:00
#include <winhttp.h>
using InternetHandle = AutoHandle<Functor<WinHttpCloseHandle>>;
2019-06-13 16:01:29 +08:00
struct HttpRequest
2019-02-11 10:46:39 +08:00
{
2019-06-13 16:01:29 +08:00
HttpRequest(
const wchar_t* agentName,
const wchar_t* serverName,
const wchar_t* action,
const wchar_t* objectName,
DWORD requestFlags = WINHTTP_FLAG_SECURE | WINHTTP_FLAG_ESCAPE_DISABLE,
const wchar_t* httpVersion = NULL,
const wchar_t* referrer = NULL,
const wchar_t** acceptTypes = NULL,
const wchar_t* headers = NULL,
void* body = NULL,
DWORD bodyLength = 0
);
operator bool() { return errorCode == ERROR_SUCCESS; }
std::wstring response;
InternetHandle connection = NULL;
InternetHandle request = NULL;
DWORD errorCode = ERROR_SUCCESS;
2019-06-06 08:26:50 +08:00
};
2019-06-13 16:01:29 +08:00
std::wstring Escape(const std::wstring& text);
void Unescape(std::wstring& text);