From: Stefan Bund Date: Thu, 27 Jan 2011 16:59:57 +0000 (+0100) Subject: add _httpapi.get X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=4cb225e1cf1dec430a6666158d0ccc11f2dd1c82;p=pykit.git add _httpapi.get --- diff --git a/PythonHTTP.cc b/PythonHTTP.cc index 04667d6..ab1adb6 100644 --- a/PythonHTTP.cc +++ b/PythonHTTP.cc @@ -27,6 +27,7 @@ namespace { { public: void post(QString const & url, QByteArray const & data, boost::python::object callback); + void get(QString const & url, boost::python::object callback); private: QNetworkAccessManager mgr_; @@ -76,6 +77,14 @@ prefix_ void Manager::post(QString const & url, QByteArray const & data, new ReplyHandler(callback, reply); } +prefix_ void Manager::get(QString const & url, boost::python::object callback) +{ + QNetworkRequest req; + req.setUrl(QUrl(url)); + QNetworkReply * reply (mgr_.get(req)); + new ReplyHandler(callback, reply); +} + prefix_ ReplyHandler::ReplyHandler(boost::python::object callback, QNetworkReply * reply) : callback_ (callback), reply_ (reply) { @@ -110,6 +119,7 @@ BOOST_PYTHON_MODULE(_httpapi) { py::class_("Manager") .def("post", &Manager::post) + .def("get", &Manager::get) ; py::def("timeout", &timeout);