Code Monkey home page Code Monkey logo

httpinterface's Introduction

HttpInterface:Windows上C++封装的HTTP库,包含三种实现模式(WinInet、WinHttp、socket)

主要实现了HTTP的get\post方法,下载到内存、下载到本地文件,回调下载进度等接口 测试程序中展现了常用的几个方法。

更新记录

2019-09-10
(1)修复WinInet实现库中的若干bug(下载到缓存中数据不对、http请求返回字符串\0截断……);
(2)WinInet & WinHttp实现库支持https协议;
(3)测试https下载、请求

接口声明

//接口类声明:  
class IHttpBase  
{  
public:  
	virtual void	SetDownloadCallback(IHttpCallback* pCallback, void* pParam)= 0;  
	virtual bool	DownloadFile(LPCWSTR lpUrl, LPCWSTR lpFilePath)= 0;  
	virtual bool	DownloadToMem(LPCWSTR lpUrl, OUT void** ppBuffer, OUT int* nSize)= 0;
	virtual void	FreeInstance()= 0;
	virtual HttpInterfaceError GetErrorCode()= 0;
};

////////////////////////////////////////////////////////////////////////////////////
//HTTP请求接口类
class IWininetHttp :public IHttpBase
{
public:
	//HTTP请求功能
	virtual string	Request(LPCSTR lpUrl, HttpRequest type, LPCSTR lpPostData = NULL, LPCSTR lpHeader = NULL)= 0;
	virtual string	Request(LPCWSTR lpUrl, HttpRequest type, LPCSTR lpPostData = NULL, LPCWSTR lpHeader = NULL)= 0;
};
///////////////////////////////////////////////////////////////////////////////////////

//HTTP socket类
class ISocketHttp :public IHttpBase
{
public:
	virtual LPCWSTR	GetIpAddr()const= 0;
};

///////////////////////////////////////////////////////////////////////////////////////

//WinHttp类
class IWinHttp : public IWininetHttp
{
public:
	//设置超时时间,单位:毫秒
	virtual void	SetTimeOut(int dwConnectTime,  int dwSendTime, int dwRecvTime)= 0;	
};

问题反馈

能力有限,有bug欢迎指正 email:[email protected]

httpinterface's People

Contributors

jelinyao avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.