From bc95e5135ac6263ffd13fc29de221e986a6e021d Mon Sep 17 00:00:00 2001 From: Roman Vladimirov Date: Tue, 2 Jan 2024 14:39:01 +0300 Subject: [PATCH] * remaked state for headers + added manifests for winget --- .../0.0.12/EmptyFlow.ArdorQuery.installer.yaml | 14 ++++++++++++++ .../0.0.12/EmptyFlow.ArdorQuery.locale.en-US.yaml | 12 ++++++++++++ .../ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.yaml | 8 ++++++++ src/ViewModels/httpperformerviewmodel.cpp | 6 ++---- src/ViewModels/httprequestresultviewmodel.cpp | 12 +++++++----- src/ViewModels/httprequestresultviewmodel.h | 5 +++-- 6 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.installer.yaml create mode 100644 manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.locale.en-US.yaml create mode 100644 manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.yaml diff --git a/manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.installer.yaml b/manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.installer.yaml new file mode 100644 index 0000000..c57a96c --- /dev/null +++ b/manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.installer.yaml @@ -0,0 +1,14 @@ +# Created using wingetcreate 1.5.7.0 +# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.5.0.schema.json + +PackageIdentifier: EmptyFlow.ArdorQuery +PackageVersion: 0.0.12 +InstallerLocale: en-US +InstallerType: msi +ProductCode: '{EBE34EE1-85DB-4115-A8EB-59FD029384B7}' +Installers: +- InstallerUrl: https://github.com/trueromanus/ArdorQuery/releases/download/0.0.12/windows_installer-0.0.12.msi + Architecture: x64 + InstallerSha256: 8BE80BD76C654F4AF48B18235EB91F24C35D771ECEA469F1784E955A0F608488 +ManifestType: installer +ManifestVersion: 1.5.0 diff --git a/manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.locale.en-US.yaml b/manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.locale.en-US.yaml new file mode 100644 index 0000000..d005b95 --- /dev/null +++ b/manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.locale.en-US.yaml @@ -0,0 +1,12 @@ +# Created using wingetcreate 1.5.7.0 +# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.5.0.schema.json + +PackageIdentifier: EmptyFlow.ArdorQuery +PackageVersion: 0.0.12 +PackageLocale: en-US +Publisher: EmptyFlow +PackageName: ArdorQuery +License: GPL3 +ShortDescription: Cross-platform tool for performing any HTTP(S) endpoints like REST API, HTML, Images, GraphQL, OData etc. +ManifestType: defaultLocale +ManifestVersion: 1.5.0 diff --git a/manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.yaml b/manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.yaml new file mode 100644 index 0000000..2799251 --- /dev/null +++ b/manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.yaml @@ -0,0 +1,8 @@ +# Created using wingetcreate 1.5.7.0 +# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.5.0.schema.json + +PackageIdentifier: EmptyFlow.ArdorQuery +PackageVersion: 0.0.12 +DefaultLocale: en-US +ManifestType: version +ManifestVersion: 1.5.0 diff --git a/src/ViewModels/httpperformerviewmodel.cpp b/src/ViewModels/httpperformerviewmodel.cpp index 0f05eda..14e65ad 100644 --- a/src/ViewModels/httpperformerviewmodel.cpp +++ b/src/ViewModels/httpperformerviewmodel.cpp @@ -458,13 +458,11 @@ void HttpPerformerViewModel::requestFinished(QNetworkReply *reply) if (status_code.isValid()) result->setStatusCode(status_code.toInt()); QStringList responseHeaders; - QStringList rawHeaders; auto headers = reply->rawHeaderPairs(); foreach (auto header, headers) { auto name = header.first; auto value = header.second; - responseHeaders.append("" + name + ": " + value); - rawHeaders.append(name + " " + value); + responseHeaders.append(name + " " + value); } result->setHeaders(responseHeaders); if (reply->isReadable()) result->setBody(reply->readAll()); @@ -473,7 +471,7 @@ void HttpPerformerViewModel::requestFinished(QNetworkReply *reply) if (postScript.isEmpty()) return; auto response = new PostScriptResponseModel(); - response->setHeaders(rawHeaders); + response->setHeaders(responseHeaders); response->setStatusCode(status_code.toInt()); response->setErrorMessage(result->networkError()); response->setBodySize(result->originResponseSize()); diff --git a/src/ViewModels/httprequestresultviewmodel.cpp b/src/ViewModels/httprequestresultviewmodel.cpp index af7ba06..fe09864 100644 --- a/src/ViewModels/httprequestresultviewmodel.cpp +++ b/src/ViewModels/httprequestresultviewmodel.cpp @@ -41,8 +41,12 @@ void HttpRequestResultViewModel::setStatusCode(const int statusCode) noexcept void HttpRequestResultViewModel::setHeaders(const QStringList &headers) noexcept { m_headers.clear(); + m_displayHeaders.clear(); foreach (auto header, headers) { m_headers.append(header); + auto spaceIndex = header.indexOf(" "); + auto mid = StartHeaderTag + header.mid(0, spaceIndex) + EndHeaderTag; + m_displayHeaders.append(mid + header.mid(spaceIndex + 1)); } emit headersChanged(); @@ -252,7 +256,7 @@ void HttpRequestResultViewModel::copyHeadersToClipboard() if (m_headers.isEmpty()) return; QClipboard *clipboard = QGuiApplication::clipboard(); - clipboard->setText(m_headers.join("\n").replace("", "").replace("", "")); + clipboard->setText(m_headers.join("\n")); } void HttpRequestResultViewModel::copyBodyToClipboard() @@ -314,11 +318,11 @@ QString HttpRequestResultViewModel::getFormatFromContentType() noexcept QString contentTypeHeader = ""; QString contentDisposition = ""; foreach (auto header, m_headers) { - if (header.contains("content-type:", Qt::CaseInsensitive)) { + if (header.startsWith("content-type ", Qt::CaseInsensitive)) { contentTypeHeader = header.toLower(); continue; } - if (header.contains("content-disposition:", Qt::CaseInsensitive)) { + if (header.startsWith("content-disposition ", Qt::CaseInsensitive)) { contentDisposition = header.toLower(); continue; } @@ -400,8 +404,6 @@ QStringList HttpRequestResultViewModel::getHeaderLines() QStringList lines; foreach (auto header, m_headers) { auto clearedHeader = QString(header) - .replace(StartHeaderTag, "") - .replace(EndHeaderTag, "") .replace("\n", "") .replace("\r", ""); if (clearedHeader.size() > lineCount) { diff --git a/src/ViewModels/httprequestresultviewmodel.h b/src/ViewModels/httprequestresultviewmodel.h index c72ae4c..4821cd8 100644 --- a/src/ViewModels/httprequestresultviewmodel.h +++ b/src/ViewModels/httprequestresultviewmodel.h @@ -47,6 +47,7 @@ class HttpRequestResultViewModel : public QObject private: int m_statusCode { 0 }; QStringList m_headers { QStringList() }; + QStringList m_displayHeaders { QStringList() }; QElapsedTimer* m_elapsedTimer { nullptr }; bool m_hasResultTime { false }; uint64_t m_elapsedTime { 0 }; @@ -66,7 +67,7 @@ class HttpRequestResultViewModel : public QObject bool m_showDownloadFile { false }; QString m_defaultDownloadFile { "" }; const QString StartHeaderTag { "" }; - const QString EndHeaderTag { "" }; + const QString EndHeaderTag { ": " }; public: explicit HttpRequestResultViewModel(QObject *parent = nullptr); @@ -74,7 +75,7 @@ class HttpRequestResultViewModel : public QObject int statusCode() const noexcept { return m_statusCode; } void setStatusCode(const int statusCode) noexcept; - QStringList headers() const noexcept { return m_headers; } + QStringList headers() const noexcept { return m_displayHeaders; } void setHeaders(const QStringList& headers) noexcept; void setBody(const QByteArray& body) noexcept;