#include "WinHttpFetcher.hpp" #include "WinHttpRewindInputStream.hpp" #include "win32/errormsg.hpp" #include #include WinHttpFetcher::WinHttpFetcher( ) : m_session( 0 ) { m_session = WinHttpOpen( L"WinHTTP crawler/0.0.1", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0 ); if( !m_session ) { std::ostringstream ss; ss << "Error creating WinHttp session: " << getLastError( ); throw std::runtime_error( ss.str( ) ); } } WinHttpFetcher::~WinHttpFetcher( ) { WinHttpCloseHandle( m_session ); } RewindInputStream *WinHttpFetcher::fetch( const URL url ) { WinHttpRewindInputStream *s = new WinHttpRewindInputStream( url, this ); return s; } REGISTER_MODULE( "winhttp_fetcher", 0, 0, Fetcher, WinHttpFetcher )