本文整理汇总了C++中Http::get_recv_header方法的典型用法代码示例。如果您正苦于以下问题:C++ Http::get_recv_header方法的具体用法?C++ Http::get_recv_header怎么用?C++ Http::get_recv_header使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Http
的用法示例。
在下文中一共展示了Http::get_recv_header方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: head
void stage_3(string &url)
{
rsprintf("Lacze z '%s' (3)", url.c_str());
rs_progress_start = Time::in_usec();
rs_info.status = RS::Downloading;
rs_info.bytes = 0;
rs_info.tmpspeed = 0;
off_t length = 0;
try { // TODO
int code = http.get(rs_download_get_path(rs_info.url.c_str()).string().c_str(), length, url.c_str(),
"mirror=", NULL, rs_progress_callback, NULL);
filesystem::ofstream head(rs_sessions_get_path(url, "-head3.http"));
head.write(http.get_recv_header(), strlen(http.get_recv_header()));
if (code == HTTP_OK) // Oczekujemy kodu 200
rsprintf("Polaczono, code = %d, length = %lld", code, length);
else {
rsprintf("Polaczono, brak strony? code = %d, length = %lld, try again", code, length);
throw DBreak();
}
//string clen = http.get_recv_header("content-length");
//rsprintf("");
}
catch (Exception &e) {
rsprintf("Nastapil wyjatek: %s", e.what());
throw DBreak();
}
}
示例2: main
int main(int argc, char **argv)
{
Http http;
char *page = NULL;
size_t size = 0;
for (int i = 1; i < argc; ++i) {
cerr << "== GET '" << argv[i] << "' ==" << endl;
try {
//http.set_verbose(true);
int code = http.get(page, size, argv[i]);
if (page) delete[] page;
const Http::Headers &hdrs = http.get_headers();
Http::Headers::const_iterator it;
const char *loc = http.get_recv_header("location");
const char *coo = http.get_recv_header("set-cookie");
const char *len = http.get_recv_header("content-length");
cerr << "== code = " << code << endl;
cerr << "== headers size = " << hdrs.size() << endl;
cerr << "== location = " << (loc?loc:"?") << endl;
cerr << "== set-cookie = " << (coo?coo:"?") << endl;
cerr << "== content-length = " << (len?len:"?") << " (strona: " << size << ")"<< endl;
}
catch (Exception &e) {
cerr << "== exception: " << e.what() << endl;
}
}
return 0;
}