mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 15:37:26 -06:00
@@ -176,11 +176,11 @@ bool Connection::acceptsGzipEncoding(QString codings)
|
||||
if (list.isEmpty())
|
||||
return false;
|
||||
|
||||
const bool canGzip = isCodingAvailable(list, QString::fromLatin1("gzip"));
|
||||
const bool canGzip = isCodingAvailable(list, u"gzip"_qs);
|
||||
if (canGzip)
|
||||
return true;
|
||||
|
||||
const bool canAny = isCodingAvailable(list, QString::fromLatin1("*"));
|
||||
const bool canAny = isCodingAvailable(list, u"*"_qs);
|
||||
if (canAny)
|
||||
return true;
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
#include "httperror.h"
|
||||
|
||||
#include "base/global.h"
|
||||
|
||||
HTTPError::HTTPError(const int statusCode, const QString &statusText, const QString &message)
|
||||
: RuntimeError {message}
|
||||
, m_statusCode {statusCode}
|
||||
@@ -46,41 +48,41 @@ QString HTTPError::statusText() const
|
||||
}
|
||||
|
||||
BadRequestHTTPError::BadRequestHTTPError(const QString &message)
|
||||
: HTTPError(400, QLatin1String("Bad Request"), message)
|
||||
: HTTPError(400, u"Bad Request"_qs, message)
|
||||
{
|
||||
}
|
||||
|
||||
UnauthorizedHTTPError::UnauthorizedHTTPError(const QString &message)
|
||||
: HTTPError(401, QLatin1String("Unauthorized"), message)
|
||||
: HTTPError(401, u"Unauthorized"_qs, message)
|
||||
{
|
||||
}
|
||||
|
||||
ForbiddenHTTPError::ForbiddenHTTPError(const QString &message)
|
||||
: HTTPError(403, QLatin1String("Forbidden"), message)
|
||||
: HTTPError(403, u"Forbidden"_qs, message)
|
||||
{
|
||||
}
|
||||
|
||||
NotFoundHTTPError::NotFoundHTTPError(const QString &message)
|
||||
: HTTPError(404, QLatin1String("Not Found"), message)
|
||||
: HTTPError(404, u"Not Found"_qs, message)
|
||||
{
|
||||
}
|
||||
|
||||
MethodNotAllowedHTTPError::MethodNotAllowedHTTPError(const QString &message)
|
||||
: HTTPError(405, QLatin1String("Method Not Allowed"), message)
|
||||
: HTTPError(405, u"Method Not Allowed"_qs, message)
|
||||
{
|
||||
}
|
||||
|
||||
ConflictHTTPError::ConflictHTTPError(const QString &message)
|
||||
: HTTPError(409, QLatin1String("Conflict"), message)
|
||||
: HTTPError(409, u"Conflict"_qs, message)
|
||||
{
|
||||
}
|
||||
|
||||
UnsupportedMediaTypeHTTPError::UnsupportedMediaTypeHTTPError(const QString &message)
|
||||
: HTTPError(415, QLatin1String("Unsupported Media Type"), message)
|
||||
: HTTPError(415, u"Unsupported Media Type"_qs, message)
|
||||
{
|
||||
}
|
||||
|
||||
InternalServerErrorHTTPError::InternalServerErrorHTTPError(const QString &message)
|
||||
: HTTPError(500, QLatin1String("Internal Server Error"), message)
|
||||
: HTTPError(500, u"Internal Server Error"_qs, message)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ bool RequestParser::parseRequestLine(const QString &line)
|
||||
{
|
||||
// [rfc7230] 3.1.1. Request Line
|
||||
|
||||
const QRegularExpression re(QLatin1String("^([A-Z]+)\\s+(\\S+)\\s+HTTP\\/(\\d\\.\\d)$"));
|
||||
const QRegularExpression re(u"^([A-Z]+)\\s+(\\S+)\\s+HTTP\\/(\\d\\.\\d)$"_qs);
|
||||
const QRegularExpressionMatch match = re.match(line);
|
||||
|
||||
if (!match.hasMatch())
|
||||
@@ -268,7 +268,7 @@ bool RequestParser::parsePostMessage(const QByteArray &data)
|
||||
// [rfc2046] 5.1.1. Common Syntax
|
||||
|
||||
// find boundary delimiter
|
||||
const QLatin1String boundaryFieldName("boundary=");
|
||||
const QString boundaryFieldName = u"boundary="_qs;
|
||||
const int idx = contentType.indexOf(boundaryFieldName);
|
||||
if (idx < 0)
|
||||
{
|
||||
@@ -347,8 +347,8 @@ bool RequestParser::parseFormData(const QByteArray &data)
|
||||
}
|
||||
|
||||
// pick data
|
||||
const QLatin1String filename("filename");
|
||||
const QLatin1String name("name");
|
||||
const QString filename = u"filename"_qs;
|
||||
const QString name = u"name"_qs;
|
||||
|
||||
if (headersMap.contains(filename))
|
||||
{
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "base/global.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace Http
|
||||
@@ -35,7 +38,7 @@ namespace Http
|
||||
class ResponseBuilder
|
||||
{
|
||||
public:
|
||||
void status(uint code = 200, const QString &text = QLatin1String("OK"));
|
||||
void status(uint code = 200, const QString &text = u"OK"_qs);
|
||||
void setHeader(const Header &header);
|
||||
void print(const QString &text, const QString &type = CONTENT_TYPE_HTML);
|
||||
void print(const QByteArray &data, const QString &type = CONTENT_TYPE_HTML);
|
||||
|
||||
@@ -74,13 +74,13 @@ QString Http::httpDate()
|
||||
// [RFC 7231] 7.1.1.1. Date/Time Formats
|
||||
// example: "Sun, 06 Nov 1994 08:49:37 GMT"
|
||||
|
||||
return QLocale::c().toString(QDateTime::currentDateTimeUtc(), QLatin1String("ddd, dd MMM yyyy HH:mm:ss"))
|
||||
.append(QLatin1String(" GMT"));
|
||||
return QLocale::c().toString(QDateTime::currentDateTimeUtc(), u"ddd, dd MMM yyyy HH:mm:ss"_qs)
|
||||
.append(u" GMT");
|
||||
}
|
||||
|
||||
void Http::compressContent(Response &response)
|
||||
{
|
||||
if (response.headers.value(HEADER_CONTENT_ENCODING) != QLatin1String("gzip"))
|
||||
if (response.headers.value(HEADER_CONTENT_ENCODING) != u"gzip")
|
||||
return;
|
||||
|
||||
response.headers.remove(HEADER_CONTENT_ENCODING);
|
||||
@@ -106,5 +106,5 @@ void Http::compressContent(Response &response)
|
||||
return;
|
||||
|
||||
response.content = compressedData;
|
||||
response.headers[HEADER_CONTENT_ENCODING] = QLatin1String("gzip");
|
||||
response.headers[HEADER_CONTENT_ENCODING] = u"gzip"_qs;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Http
|
||||
HeaderMap headers;
|
||||
QByteArray content;
|
||||
|
||||
Response(uint code = 200, const QString &text = QLatin1String("OK"))
|
||||
Response(uint code = 200, const QString &text = u"OK"_qs)
|
||||
: status {code, text}
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user