create interface
This commit is contained in:
@@ -2,21 +2,26 @@
|
||||
|
||||
STOMPFrame::STOMPFrame(Command command, std::initializer_list<QPair<QString, QString>> headers, const QByteArray& body):
|
||||
command_(command), body_(body) {
|
||||
|
||||
for (const auto& header: headers) {
|
||||
headers_[header.first] = header.second;
|
||||
}
|
||||
}
|
||||
|
||||
qint64 STOMPFrame::send(QIODevice& device) {
|
||||
|
||||
QByteArray encoded;
|
||||
QTextStream out {&encoded};
|
||||
out << command_ << "\n";
|
||||
|
||||
for (const auto& key: headers_.keys()) {
|
||||
out << key << ":" << headers_[key] << "\n";
|
||||
}
|
||||
|
||||
if (!headers_.contains("content-length")) {
|
||||
out << "content-length" << ":" << body_.size() << "\n";
|
||||
}
|
||||
|
||||
out << "\n" << body_ << '\0';
|
||||
out.flush();
|
||||
return device.write(encoded);
|
||||
|
||||
Reference in New Issue
Block a user