Add-Ons & Services

Doubt in Poco sample of httpget.cpp

General discussion regarding the development of POCO for contributors.
Posts: 7
Joined: 20 Oct 2008, 14:48

Doubt in Poco sample of httpget.cpp

Postby AnithaSubramani » 21 Oct 2008, 11:41

Hi All,

I have a doubt in poco Net library. I have download and installed the Poco for windows. Im running the "httpget.cpp" in Visual Studio 2005.I need to give the URL name like "http://www.google.com".I dont know how to implement this. Where should i give this url path.

Code: Select all

#include "Poco/Net/HTTPClientSession.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/StreamCopier.h"
#include "Poco/Path.h"
#include "Poco/URI.h"
#include "Poco/Exception.h"

using Poco::Net::HTTPClientSession;
using Poco::Net::HTTPRequest;
using Poco::Net::HTTPResponse;
using Poco::Net::HTTPMessage;
using Poco::StreamCopier;
using Poco::Path;
using Poco::URI;
using Poco::Exception;

int main(int argc, char** argv)
   if (argc != 2)
      Path p(argv[0]);
      std::cout << "usage: " << p.getBaseName() << " " << std::endl;
      std::cout << "       fetches the resource identified by and print it to the standard output" << std::endl;
      return 1;

      URI uri(argv[1]);
      std::string path(uri.getPathAndQuery());
      if (path.empty()) path = "/";

      HTTPClientSession session(uri.getHost(), uri.getPort());
      HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1);
      HTTPResponse res;
      std::istream& rs = session.receiveResponse(res);
      std::cout << res.getStatus() << " " << res.getReason() << std::endl;
      StreamCopier::copyStream(rs, std::cout);
   catch (Exception& exc)
      std::cerr << exc.displayText() << std::endl;
      return 1;
   return 0;

Please help me..........................

Thanks & Regards


Posts: 1234
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Doubt in Poco sample of httpget.cpp

Postby alex » 21 Oct 2008, 13:08

>I dont know how to implement this. Where should i give this url path.

As the first argument on the command line:

Code: Select all

c:httpget http://www.google.com

>Please help me..........................

If you don't mind me suggesting, before embarking on this journey you may want to spend some time familiarizing yourself with the basics of C++.

Return to “Contributors”

Who is online

Users browsing this forum: No registered users and 0 guests