Skip to content

Commit

Permalink
* remaked state for headers
Browse files Browse the repository at this point in the history
+ added manifests for winget
  • Loading branch information
trueromanus committed Jan 2, 2024
1 parent 19639f7 commit bc95e51
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions src/ViewModels/httpperformerviewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("<font color='#8812a1'>" + name + ":</font> " + value);
rawHeaders.append(name + " " + value);
responseHeaders.append(name + " " + value);
}
result->setHeaders(responseHeaders);
if (reply->isReadable()) result->setBody(reply->readAll());
Expand All @@ -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());
Expand Down
12 changes: 7 additions & 5 deletions src/ViewModels/httprequestresultviewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -252,7 +256,7 @@ void HttpRequestResultViewModel::copyHeadersToClipboard()
if (m_headers.isEmpty()) return;

QClipboard *clipboard = QGuiApplication::clipboard();
clipboard->setText(m_headers.join("\n").replace("<font color='#8812a1'>", "").replace("</font>", ""));
clipboard->setText(m_headers.join("\n"));
}

void HttpRequestResultViewModel::copyBodyToClipboard()
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions src/ViewModels/httprequestresultviewmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -66,15 +67,15 @@ class HttpRequestResultViewModel : public QObject
bool m_showDownloadFile { false };
QString m_defaultDownloadFile { "" };
const QString StartHeaderTag { "<font color='#8812a1'>" };
const QString EndHeaderTag { "</font>" };
const QString EndHeaderTag { ":</font> " };

public:
explicit HttpRequestResultViewModel(QObject *parent = nullptr);

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;
Expand Down

0 comments on commit bc95e51

Please sign in to comment.