kdirshare: adjust to KHTTP changes

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-05-10 14:52:32 +03:00
parent 1c4fee822d
commit aeeae815ba
3 changed files with 9 additions and 4 deletions

View file

@ -34,7 +34,7 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QCheckBox" name="randombox"> <widget class="QCheckBox" name="randombox">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If the random port option is on then a random port will be used for the server in the range of values specified on the right. Otherwise, the server will always use the same port.&lt;/p&gt;&lt;p&gt;If, for example, firewall is used then using specifiec port and unblocking it in the firewall is the way to go.&lt;/p&gt;&lt;p&gt;There is a chance another service may be using the port, if that happens the server will not start.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If the random port option is on then a random port in the range of values specified on the right will be used by the server. Otherwise, the server will always use the same port.&lt;/p&gt;&lt;p&gt;If, for example, firewall is used then using specifiec port and unblocking it in the firewall is the way to go.&lt;/p&gt;&lt;p&gt;There is a chance another service may be using the port, if that happens the server will not start.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Use random port</string> <string>Use random port</string>

View file

@ -181,7 +181,9 @@ QString KDirShareImpl::publishError() const
// for reference: // for reference:
// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes // https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
void KDirShareImpl::respond(const QByteArray &url, QByteArray *outdata, ushort *outhttpstatus, KHTTPHeaders *outheaders) void KDirShareImpl::respond(const QByteArray &url, QByteArray *outdata,
ushort *outhttpstatus, KHTTPHeaders *outheaders,
QString *outfilepath)
{ {
// qDebug() << Q_FUNC_INFO << url; // qDebug() << Q_FUNC_INFO << url;
@ -219,7 +221,7 @@ void KDirShareImpl::respond(const QByteArray &url, QByteArray *outdata, ushort *
const QString filemime = KMimeType::findByPath(pathinfo.filePath())->name(); const QString filemime = KMimeType::findByPath(pathinfo.filePath())->name();
*outhttpstatus = 200; *outhttpstatus = 200;
outheaders->insert("Content-Type", QString::fromLatin1("%1; charset=UTF-8").arg(filemime).toAscii()); outheaders->insert("Content-Type", QString::fromLatin1("%1; charset=UTF-8").arg(filemime).toAscii());
outdata->append(pathfile.readAll()); outfilepath->append(pathinfo.filePath());
}; };
} else { } else {
outdata->append(s_data404); outdata->append(s_data404);

View file

@ -43,7 +43,10 @@ public:
QString publishError() const; QString publishError() const;
protected: protected:
void respond(const QByteArray &url, QByteArray *outdata, ushort *outhttpstatus, KHTTPHeaders *outheaders) final; void respond(
const QByteArray &url,
QByteArray *outdata, ushort *outhttpstatus, KHTTPHeaders *outheaders, QString *outfilepath
) final;
private: private:
QString m_directory; QString m_directory;