Get访问HTTP服务器
来源:互联网 发布:淘宝在哪里修改配送地 编辑:程序博客网 时间:2024/06/05 02:56
#include <cc++/common.h>
#include <iostream>
#include <cstdlib>
#ifdef CCXX_NAMESPACES
using namespace std;
using namespace ost;
#endif
class myURLStream : public URLStream
{
private:
void httpHeader(const char *header, const char *value)
{
cout << "HEADER " << header << "=" << value << endl;
}
};
int main(int argc, char **argv)
{
myURLStream url;
char cbuf[1024];
URLStream::Error status;
int len;
const char* addr = "http://www.webservicex.net/globalweather.asmx/GetWeather?CityName=beijing&CountryName=china";
#ifdef CCXX_EXCEPTIONS
try
{
#endif
status = url.get(addr);
if(status)
{
cout << "failed; reason=" << status << endl;
url.close();
}
else{
cout << "loading..." << endl;
while(!url.eof())
{
url.read(cbuf, sizeof(cbuf));
len = url.gcount();
if(len > 0)
cout.write(cbuf, len);
}
url.close();
cout << ends;
}
#ifdef CCXX_EXCEPTIONS
}
catch(...)
{
cerr << "url " << addr << " failed" << endl;
}
#endif
return 0;
}
#include <iostream>
#include <cstdlib>
#ifdef CCXX_NAMESPACES
using namespace std;
using namespace ost;
#endif
class myURLStream : public URLStream
{
private:
void httpHeader(const char *header, const char *value)
{
cout << "HEADER " << header << "=" << value << endl;
}
};
int main(int argc, char **argv)
{
myURLStream url;
char cbuf[1024];
URLStream::Error status;
int len;
const char* addr = "http://www.webservicex.net/globalweather.asmx/GetWeather?CityName=beijing&CountryName=china";
#ifdef CCXX_EXCEPTIONS
try
{
#endif
status = url.get(addr);
if(status)
{
cout << "failed; reason=" << status << endl;
url.close();
}
else{
cout << "loading..." << endl;
while(!url.eof())
{
url.read(cbuf, sizeof(cbuf));
len = url.gcount();
if(len > 0)
cout.write(cbuf, len);
}
url.close();
cout << ends;
}
#ifdef CCXX_EXCEPTIONS
}
catch(...)
{
cerr << "url " << addr << " failed" << endl;
}
#endif
return 0;
}
- Get访问HTTP服务器
- Android通过get,post方式体访问http服务器
- iOS http访问post 、get
- 使用HTTP GET 和HTTP POST请求访问HTTP资源
- 使用HTTP GET 和HTTP POST请求访问HTTP资源
- Android 通过http访问服务器
- Android 通过http访问服务器
- 3.18 通过http访问服务器
- Android 通过http访问服务器
- Android 通过http访问服务器
- Android---通过http访问服务器
- JAVA通过HTTP访问:Post+Get方式
- Http访问网络之GET和POST
- HTTP GET 访问及结果读取
- http java GET请求 访问页面
- JAVA通过HTTP访问:Post+Get方式
- java通过HTTP访问:POST+GET
- HTTP(GET和POST访问URL) -- wininet
- 一个小小的托盘程序(定时关机)
- (转贴)Data type conversion sheet : C++ to .NET
- Hibernate性能优化
- SQL 经典使用
- XLoadTree 基于AJAX + XML动态加载的JS树组件的文档翻译
- Get访问HTTP服务器
- ASP function 详细列表
- 在Struts中应用AJAX
- Visual C#常用函数和方法集汇总
- 木马的隐藏与自我保护技术
- 中国人在国外误进女厕☆☆经典解释☆☆
- 定时器
- John C. Nash, «Compact Numerical Methods for Computers Linear Algebra and Function Minimisation» (Reupload)
- 用 System.Xml 读写XML