virtual void abort();
using QNetworkReply::setHeader;
+ using QNetworkReply::setRawHeader;
+ using QNetworkReply::setAttribute;
void clearResponse();
QByteArray postData() const;
prefix_ void pykit::detail::InternalServerReply::bufferPostData()
{
QVariant cl (request().header(QNetworkRequest::ContentLengthHeader));
- std::cerr << "postdata contentlength: " << (cl.isValid() ? cl.toString().toStdString() : "invalid") << "\n";
connect(postDevice_, SIGNAL(readyRead()), this, SLOT(postDataReadable()));
connect(postDevice_, SIGNAL(readChannelFinished()), this, SLOT(postDataComplete()));
postData_.open(WriteOnly);
prefix_ void pykit::detail::InternalServerReply::complete()
{
emit readyRead();
- emit readChannelFinished();
emit finished();
}
{ 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); }
reply_.setHeader(QNetworkRequest::LocationHeader, QVariant(location.c_str()));
}
+prefix_ void pykit::Request::setHeader(std::string const & header, std::string const & value)
+{
+ 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
{
QNetworkRequest const & request,
QIODevice * device)
{
- if (request.url().scheme() != "srv")
+ if (request.url().host() != "pykit")
return QNetworkAccessManager::createRequest(operation, request, device);
-
return new detail::InternalServerReply(operation, request, device, publisher_);
}