HTTP 1.1 for addressbook

This commit is contained in:
orignal 2014-12-23 21:03:00 -05:00
parent 7b5e8a9661
commit e349facd65

View File

@ -339,6 +339,7 @@ namespace client
if (!s.length()) continue; // skip empty line if (!s.length()) continue; // skip empty line
m_Subscriptions.push_back (new AddressBookSubscription (*this, s)); m_Subscriptions.push_back (new AddressBookSubscription (*this, s));
} }
LogPrint (eLogInfo, m_Subscriptions.size (), " subscriptions loaded");
} }
else else
LogPrint (eLogWarning, "subscriptions.txt not found"); LogPrint (eLogWarning, "subscriptions.txt not found");
@ -419,6 +420,7 @@ namespace client
void AddressBookSubscription::Request () void AddressBookSubscription::Request ()
{ {
// must be run in separate thread // must be run in separate thread
LogPrint (eLogInfo, "Downloading hosts from ", m_Link);
bool success = false; bool success = false;
i2p::util::http::url u (m_Link); i2p::util::http::url u (m_Link);
i2p::data::IdentHash ident; i2p::data::IdentHash ident;
@ -435,7 +437,7 @@ namespace client
{ {
std::stringstream request, response; std::stringstream request, response;
// standard header // standard header
request << "GET " << u.path_ << " HTTP/1.0\r\nHost: " << u.host_ request << "GET " << u.path_ << " HTTP/1.1\r\nHost: " << u.host_
<< "\r\nAccept: */*\r\n" << "User-Agent: Wget/1.11.4\r\n" << "Connection: close\r\n"; << "\r\nAccept: */*\r\n" << "User-Agent: Wget/1.11.4\r\n" << "Connection: close\r\n";
if (m_Etag.length () > 0) // etag if (m_Etag.length () > 0) // etag
request << i2p::util::http::ETAG << ": " << m_Etag << "\r\n"; request << i2p::util::http::ETAG << ": " << m_Etag << "\r\n";
@ -493,6 +495,7 @@ namespace client
isChunked = !header.compare (colon + 1, std::string::npos, "chunked"); isChunked = !header.compare (colon + 1, std::string::npos, "chunked");
} }
} }
LogPrint (eLogInfo, m_Link, " ETag: ", m_Etag, " Last-Modified: ", m_LastModified);
if (!response.eof ()) if (!response.eof ())
{ {
success = true; success = true;
@ -515,6 +518,7 @@ namespace client
} }
else else
LogPrint (eLogError, "Can't resolve ", u.host_); LogPrint (eLogError, "Can't resolve ", u.host_);
LogPrint (eLogInfo, "Download complete ", success ? "Success" : "Failed");
m_Book.DownloadComplete (success); m_Book.DownloadComplete (success);
} }
} }