Add winstd::http

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2023-10-01 22:49:05 +02:00
parent c1bd614597
commit d99aedecc1
2 changed files with 54 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/* /*
SPDX-License-Identifier: MIT SPDX-License-Identifier: MIT
Copyright © 1991-2023 Amebis Copyright © 1991-2023 Amebis
Copyright © 2016 GÉANT Copyright © 2016 GÉANT

53
include/WinStd/WinHTTP.h Normal file
View File

@ -0,0 +1,53 @@
/*
SPDX-License-Identifier: MIT
Copyright © 1991-2023 Amebis
Copyright © 2016 GÉANT
*/
/// \defgroup WinStdWinHTTP Windows HTTP Client
#pragma once
#include "Common.h"
#include <winhttp.h>
namespace winstd
{
/// \addtogroup WinStdWinHTTP
/// @{
///
/// HTTP handle wrapper class
///
/// \sa [WinHttpOpen function](https://learn.microsoft.com/en-us/windows/win32/api/winhttp/nf-winhttp-winhttpopen)
///
class http : public handle<HINTERNET, NULL>
{
WINSTD_HANDLE_IMPL(http, NULL)
public:
///
/// Closes a handle to the HTTP.
///
/// \sa [WinHttpCloseHandle function](https://learn.microsoft.com/en-us/windows/win32/api/winhttp/nf-winhttp-winhttpclosehandle)
///
virtual ~http()
{
if (m_h != invalid)
free_internal();
}
protected:
///
/// Closes a handle to the HTTP.
///
/// \sa [WinHttpCloseHandle function](https://learn.microsoft.com/en-us/windows/win32/api/winhttp/nf-winhttp-winhttpclosehandle)
///
void free_internal() noexcept override
{
WinHttpCloseHandle(m_h);
}
};
/// @}
}