CMNetwork/inc/hgl/network/HTTPTools.h

36 lines
1.4 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef HGL_NETWORK_HTTP_TOOLS_INCLUDE
#define HGL_NETWORK_HTTP_TOOLS_INCLUDE
#include<hgl/type/BaseString.h>
#include<hgl/io/OutputStream.h>
namespace hgl
{
namespace network
{
/**
* 网络通信中HTTP/HTTPS所使用的功能实现
*/
namespace http
{
/**
* 建立一个HTTP/HTTPS链接并发送GET操作得到返回信息<br>
* 注返回信息会包含HTTP信息头用于下载文件时需自行将信息头去掉
*/
int get(io::OutputStream *,const char *,const char *user_agent=nullptr); ///<http/https get
int post(io::OutputStream *,const char *,const void *,const int,const char *user_agent=nullptr); ///<http/htpps post
inline int post(io::OutputStream *os,const char *url,const UTF8String &post_data,const char *user_agent=nullptr)
{
return post(os,url,post_data.c_str(),post_data.Length(),user_agent);
}
inline int post(io::OutputStream *os,const UTF8String &url,const UTF8String &post_data,const char *user_agent=nullptr)
{
return post(os,url.c_str(),post_data.c_str(),post_data.Length(),user_agent);
}
}//namespace http
}//namespace network
}//namespace hgl
#endif//HGL_NETWORK_HTTP_TOOLS_INCLUDE