From: Stefan Bund Date: Tue, 21 Dec 2010 00:19:00 +0000 (+0100) Subject: add setStatusCode request api member X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=dd97af690b24459c73cf9031c20cd18a60397239;p=pykit.git add setStatusCode request api member --- diff --git a/Publisher.cc b/Publisher.cc index cd5caf3..30a6789 100644 --- a/Publisher.cc +++ b/Publisher.cc @@ -51,6 +51,7 @@ namespace detail { using QNetworkReply::setHeader; using QNetworkReply::setRawHeader; + using QNetworkReply::setAttribute; void clearResponse(); QByteArray postData() const; @@ -156,7 +157,6 @@ prefix_ void pykit::detail::InternalServerReply::processRequest() prefix_ void pykit::detail::InternalServerReply::complete() { emit readyRead(); - emit readChannelFinished(); emit finished(); } @@ -201,7 +201,12 @@ prefix_ bool pykit::detail::InternalServerReply::waitForReadyRead(int msecs) { return buffer_.waitForReadyRead(msecs); } prefix_ qint64 pykit::detail::InternalServerReply::readData(char * data, qint64 maxSize) -{ return buffer_.read(data,maxSize); } +{ + qint64 n (buffer_.read(data,maxSize)); + if (buffer_.atEnd()) + emit readChannelFinished(); + return n; +} prefix_ qint64 pykit::detail::InternalServerReply::writeData(char const * data, qint64 maxSize) { return buffer_.write(data,maxSize); } @@ -254,6 +259,11 @@ prefix_ void pykit::Request::setHeader(std::string const & header, std::string c reply_.setRawHeader(header.c_str(), value.c_str()); } +prefix_ void pykit::Request::setStatusCode(int code) +{ + reply_.setAttribute(QNetworkRequest::HttpStatusCodeAttribute, code); +} + prefix_ QUrl pykit::Request::url() const { diff --git a/Publisher.hh b/Publisher.hh index 72862d2..6cd3287 100644 --- a/Publisher.hh +++ b/Publisher.hh @@ -32,6 +32,7 @@ namespace pykit { void setContentType(std::string const & contentType); void setLocation(std::string const & location); void setHeader(std::string const & header, std::string const & value); + void setStatusCode(int code); QUrl url() const; QByteArray postData() const; diff --git a/PythonPublisher.cc b/PythonPublisher.cc index 8ab72be..fc29b6f 100644 --- a/PythonPublisher.cc +++ b/PythonPublisher.cc @@ -424,6 +424,7 @@ BOOST_PYTHON_MODULE(_pykit) .def("setContentType", &pykit::Request::setContentType) .def("setLocation", &pykit::Request::setLocation) .def("setRawHeader", &pykit::Request::setHeader) + .def("setStatusCode", &pykit::Request::setStatusCode) .def("url", &pykit::Request::url) .def("postData", &pykit::Request::postData) .def("operation", &pykit::Request::operation)