
#include "stdafx.h"
#include "winhttphandle.h"
#include "macro.h"


/*
#include "namespace_start.h"


//
//ハンドル管理
//
WinHttpHandle::WinHttpHandle() :
        m_handle(0)
    {}

WinHttpHandle::~WinHttpHandle()
    {
        Close();
    }


 Bool WinHttpHandle::Attach(HINTERNET handle)
    {
        ASSERT(0 == m_handle);
        m_handle = handle;
        return 0 != m_handle;
    }

 HINTERNET WinHttpHandle::Detach()
    {
        HANDLE handle = m_handle;
        m_handle = 0;
        return handle;
    }

 Void WinHttpHandle::Close()
    {
        if (0 != m_handle)
        {   
            VERIFY(::WinHttpCloseHandle(m_handle));
            m_handle = 0;
        }
    }


 CHResult WinHttpHandle::SetOption(DWORD option,const Void* value,DWORD length)
    {
        if (!::WinHttpSetOption(m_handle,
                                option,
                                const_cast<void*>(value),
                                length))
        {
            return HRESULT_FROM_WIN32(::GetLastError());
        }

        return S_OK;
    }

 CHResult WinHttpHandle::QueryOption(DWORD option,Void* value,DWORD& length) const
    {
        if (!::WinHttpQueryOption(m_handle,
                                  option,
                                  value,
                                  &length))
        {
            return HRESULT_FROM_WIN32(::GetLastError());
        }

        return S_OK;
    }


//
//セッション管理
//
CHResult WinHttpSession::Initialize()
{
    if (!Attach(::WinHttpOpen(0, // no agent string
                                WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
                                WINHTTP_NO_PROXY_NAME,
                                WINHTTP_NO_PROXY_BYPASS,
                                WINHTTP_FLAG_ASYNC)))
    {
        return HRESULT_FROM_WIN32(::GetLastError());
    }

    return S_OK;
}

//
//接続管理
//
CHResult WinHttpConnection::Initialize(PCWSTR serverName,INTERNET_PORT portNumber,const WinHttpSession& session)
    {
        if (!Attach(::WinHttpConnect(session.m_handle,
                                     serverName,
                                     portNumber,
                                     0))) // reserved
        {
            return HRESULT_FROM_WIN32(::GetLastError());
        }

        return S_OK;
    }




#include "namespace_end.h"
	*/