Created
January 18, 2013 18:18
-
-
Save karlr42/4566844 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Poco/Net/HTTPClientSession.h> | |
#include <Poco/Net/HTTPRequest.h> | |
#include <Poco/Net/HTTPResponse.h> | |
#include <Poco/StreamCopier.h> | |
#include <iostream> | |
/* | |
* Test case to show slow DNS lookup when making a request to a | |
* particular domain. The HTTP level in terms of the response | |
* is not that important- the actual lookup happens as part of | |
* creating a Net::SocketAddress in Net::HTTPClientSession::reconnect() | |
* | |
* Compiled with: | |
* g++ -o"PocoDNSTestCase" PocoDNSTestCase.cpp -lPocoUtil -lPocoNet | |
* and ran with : ./PocoDNSTestCase | |
*/ | |
using namespace Poco::Net; | |
#define BROKEN_DOMAIN "word-view.beta.officeapps.live.com" | |
int main(int argc, char *argv[]){ | |
//isolated test of the problem domain | |
HTTPClientSession hcs(BROKEN_DOMAIN); | |
// send request | |
HTTPRequest req(HTTPRequest::HTTP_GET, "/", HTTPMessage::HTTP_1_1); | |
hcs.sendRequest(req); //hangs here- DNS lookup takes a long time | |
// get response | |
HTTPResponse res; | |
std::cerr<< res.getStatus() << " " << res.getReason() << std::endl; | |
// print response | |
std::istream &is = hcs.receiveResponse(res); | |
Poco::StreamCopier::copyStream(is, std::cerr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment