Commit Graph

61 Commits

Author SHA1 Message Date
Matthias Rauter 6acb3ccf22 Set afterRequest callback with a context object and remove rvalue
Use QtPrivate::makeCallableObject() and a context object instead
of std::function() when calling afterRequest(). It's signature is
now constrained to take both request and response in that particular
order.

The rvalue was exchanged with a reference in the callback signature
because QMetaObject::invokeMethod is not prepared to handle rvalues.

The function is renamed to addAfterRequestHander() to clarify
its function.

Pick-to: 6.8
Task-Id: QTBUG-128113
Change-Id: If3af3b811f54fe4be2b14d5c768b3a61b4f32bb6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-09-02 08:05:04 +02:00
Matthias Rauter 76e55a052f Set missinghandler callback with a context object and remove rvalue
Use QtPrivate::makeCallableObject() and a context object instead
of std::function() when calling setMissingHandler(). Also added
clearMissingHandler() to set the handler back to the default behavior.

The rvalue was exchanged with a reference in the callback signature
because QMetaObject::invokeMethod is not prepared to handle rvalues.

Pick-to: 6.8
Task-Id: QTBUG-128113
Change-Id: If02c67a0ee200b458d9f8051a23a9307fce6e59a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-08-30 17:57:37 +02:00
Matthias Rauter 962d95298f Simplify and constrain route API
The route convenience method of QHttpServer was a purely variadic
template function. However, it expected a strict syntax of (QString,
Method, Rule parameters..., Functor). The Rule parameters are
forwarded to the constructor of the Rule that is created. This was
not documented.

The Functor is expected to follow some rules too. This is checked by
QHttpServerRouterViewTraits.

This change expresses the synatax in the function declaration as
(QString, Method, Functor) and removes the possibility to forward
parameters to the constructor of rule. The route method now returns a
pointer to the new rule, which can be used to set parameters instead.

Constraints to the Functor are still checked by QHttp...ViewTraits.

Pick-to: 6.8
Task-Id: QTBUG-128113
Change-Id: Id3d075a46e86169521bafd3ecb4c9c58ba8dff2c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-08-27 20:18:50 +02:00
Lena Biliaieva ff870498f9 QHttpServerResponse: make API simpler by removing duplicating methods
Replaced all headers-related methods with only setter and getter to make
the class interface simpler and more consistent with other classes
consuming QHttpHeaders.

Resulted from API-review

Task-number: QTBUG-125859
Pick-to: 6.8
Change-Id: Ic41b471813969711bb07302a8929784bc425c84e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-08-06 15:41:45 +02:00
Øystein Heskestad bd5ac90224 QAbstractHttpServer: Remove QSslConfiguration and listen() methods
To keep the API lean, remove the SSL confguration and listen()
methods.

Instead using listen() on a QAbstractHttpServer, a user should
create an instance of a QTcpServer or QSslServer, then call
listen() on it before calling bind() on a QAbstractHttpServer
with it as an argument.

Task-number: QTBUG-125859
Pick-to: 6.8
Change-Id: I366c0a01d8b7ee3802e0bdd63b9d84813338f478
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-07-31 16:52:41 +02:00
Øystein Heskestad 19cf2bb2c7 Make tst_QHttpServer test HTTP 2 as well
Previously tst_QHttpServer only covered HTTP/1.1 and partially HTTPS/1.1.
Now all tst_QHttpServer tests are run for HTTP/1.1, HTTPS/1.1, and HTTP/2.

Fixes: QTBUG-122457
Pick-to: 6.8
Change-Id: I068a90545365a85e62e990a14bda38e43a4bbc64
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-07-25 12:59:36 +02:00
Øystein Heskestad bbc9e5deff Change QHttpServerResponder to be suitable for both HTTP 1.1 and 2
The QHttpServerResponder class is too low level and HTTP 1.1 specific
to be used for both HTTP 1.1 and 2. Remove the low level functions and
add member functions for sending data without having to know the
total length of the data before sending it.

To respond with data with length not known before response is
generated, call one of the writeBeginChunked functions, followed by
as many calls to writeChunk as needed, and finish with a call to one
of the writeEndChunked functions.

The HTTP 1.1 implementation has been moved from QHttpServerResponder
to QHttpServerResponderPrivate.

Fixes: QTBUG-124866
Change-Id: Ie4dd6982bbbb14a5403ebcdfe85626deb5fb2cc5
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2024-05-13 14:29:07 +02:00
Lena Biliaieva bcfed45d9b Use QHttpHeaders in QHttpServerResponder
Fixes: QTBUG-120135
Change-Id: Ic0c60884b7bc1a05edf55c20b944268445c56e87
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2024-02-21 15:36:55 +01:00
Lena Biliaieva 2c91877b7f Use QHttpHeaders in QHttpServerResponse
Added withHeaders() method to pass headers to the QHttpServerResponse object.
Removed methods using QHttpServerResponder::HeaderList because it will be also replaced by QHttpHeaders.
Added headers() method for convenience.
Updated tests and examples.

Fixes: QTBUG-107749
Change-Id: Ia9ce631a17b1b60e84ffc85e09215ac262407144
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-02-13 13:03:08 +01:00
Ievgenii Meshcheriakov e47089a0e3 tst_QHttpServer::multipleResponses: Don't expect failure
The bug causing the failure (QTBUG-108068) was fixed.

Fixes: QTBUG-122154
Task-number: QTBUG-108068
Change-Id: I18d5b5a75b82947194fe68830cffaae1fe1f8fb6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-02-12 11:00:27 +01:00
Ahmad Samir 9485e56429 Mark the whole repo with QT_NO_CONTEXTLESS_CONNECT
By adding it to the default build flags via .cmake.conf.

This amends commit  f0832a1fe4.

Change-Id: Idca0dedc94691eae5db9c844b16293e7064da509
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
2023-08-21 22:47:41 +03:00
Marcus Tillmanns a14ecdb0e6 Add support for local socket/server
Change-Id: I7be8f327535aa5f7b5156b42240043117d9107c0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-07-17 12:46:37 +00:00
Ievgenii Meshcheriakov 51c37b7ef7 Decay type passed to FunctionTraits
This allows for uniform handling of functions, function
pointers and function pointer references.

Update tst_qhttpserverrouter to use a static function in
addition to lambdas.

Update tst_qhttpserver to use lambda variables, functions,
function pointers, and a class with a custom call operator
for route handlers.

Fixes: QTBUG-112484
Pick-to: 6.5
Change-Id: I19713105c1bacf3365057b70d17e6211e05f8ab9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-04-25 14:16:21 +02:00
Juha Vuolle 1308cb053b Remove few small compilation warnings
Pick-to: 6.5
Change-Id: I2693f05fe357f30767ecd7d901cdb9ff66fdeea3
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-01-25 08:32:21 +02:00
Ievgenii Meshcheriakov d38ffaa0ac Remove QHttpServerResponse::write() and add QHttpServerResponder::writeResponse()
This allows to send more than a single response to a client.

Add an expected-failure (due to QTBUG-108068) test that produces
multiple responses.

[ChangeLog][QHttpServerResponse][Potentially Source-Incompatible Changes]
QHttpServerResponse::write() method was removed in favor of new
QHttpServerResponder::writeResponse().

Task-number: QTBUG-105202
Change-Id: I79f3297d1a4360634715be8593a6b146304d481f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-14 11:16:02 +01:00
Ievgenii Meshcheriakov 55d10201dc Add connection tracking
Introduce private QHttpServerStream class that handles connection
state. This is the only class that contains a connected QTcpSocket.
Make other classes use QHttpServerResponder to communicate
with clients. Stop processing of further requests as long as a
QHttpServerResponder object for the current request is active.

Add a regression test to tst_qhttpserver.

[ChangeLog][Potentially Source-Incompatible Changes] Most public
methods that accepted a QTcpSocket are now accepting
QHttpServerResponder instead.

Task-number: QTBUG-105202
Change-Id: Ib8db7fdc65b59077411b09277f2b1948fde4848b
Reviewed-by: André Klitzing <aklitzing@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-14 11:15:59 +01:00
Ievgenii Meshcheriakov 9da514a0fa QAbstractHttpServer: Convert missingHandler() to a pure virtual method
This ensures that there is exactly one handler. This also should make
it easier to rework the response handling.

Pick-to: 6.4
Change-Id: I5771d94a0b2436b2ff2b745335184a80f4b2cf31
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-08-25 14:16:00 +02:00
Konrad Kujawa 70fff87eb2 Overload QHttpServerResponse with status codes
Add a status code to overloaded constructor of the QHttpServerResponse

Pick-to: 6.4
Fixes: QTBUG-105366
Change-Id: I3ac95df744484319e02ac6f7e24899e0b0368334
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2022-08-10 08:39:26 +00:00
Ievgenii Meshcheriakov 02d9cd1da2 QHttpServerRequest: Cleanup Method enum
Add a value for TRACE method from RFC 7231.

Rename value All to AnyKnown.

Document the enum.

Fixes: QTBUG-105306
Task-number: QTBUG-100868
Pick-to: 6.4
Change-Id: Ibfc41d006df3dd7f2620cd9b2395b6b1b8ce6384
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-08-09 14:14:34 +00:00
Ievgenii Meshcheriakov 4a5c4487e7 tst_qhttpserver: Remove an unused #include of a private header
Also make the test non-private.

Pick-to: 6.4
Change-Id: I17eacc80e2b96443a4b8637d5e0df5bc88d583e2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-08-09 16:14:31 +02:00
Ievgenii Meshcheriakov 1e8551ca16 QHttpServerLiterals: Inline literals in tests and unexport them
Also make tst_qhttpserverresponder and tst_qhttpserverresponse
public.

Pick-to: 6.4
Change-Id: I1b95d20c86799a6f1088e54599128b07f8290f6f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-08-09 11:04:58 +02:00
Ievgenii Meshcheriakov 9dccc52f4c QAbstractHttpServerPrivate: Fix reading of pipelined requests
The server socket may contain data for multiple requests
if the network client is performing HTTP pipelining.
This patch retriggers socket's readyRead() signal after
processing a request so that the server can handle next
pipelined request.

Pick-to: 6.4
Change-Id: Ifadd9cd5ff043b513ec7b831d4156d8ad5dece79
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-08-03 11:14:36 +02:00
Ievgenii Meshcheriakov 9363549ed0 QHttpServerRequest: Make headers() return a QtNetwork compatible type
Return QList<QPair<QByteArray, QByteArray>> instead of QVariantMap.

Task-number: QTBUG-100868
Pick-to: 6.4
Change-Id: I05da8b3ea15f1b7037d625c4d0ea320fca3e1016
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-07-29 15:32:19 +02:00
Ievgenii Meshcheriakov 9c69255f07 Remove support for supplying request methods as strings
This support was implemented by duplicating enum values for
QHttpServerRequest::Method. Among other things this causes
build errors on Windows due to Windows API defining DELETE.
There is also no compile time checking for valideness of
methods supplied as strings.

This partially reverts be06bd66b8.

Fixes: QTBUG-104710
Task-number: QTBUG-100868
Pick-to: 6.4
Change-Id: I47977c5979d00a1847a210b10c9f77f753880344
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-07-29 15:32:10 +02:00
Ievgenii Meshcheriakov 9b8f3a47ae Make QHttpServerResponse non-polymorphic
Remove QHttpServerFutureResponse and use QFuture<QHttpServerResponse>
instead.

Test for feature 'future' instead of 'concurrent' when only QFuture
is used.

Task-number: QTBUG-100868
Pick-to: 6.4
Change-Id: Iba318e89221afa69e46b3341ce222125421a22c6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-07-26 09:28:06 +00:00
Ievgenii Meshcheriakov 12b2d70a0a Don't move out handler lambda when serving requests
Moving out the lambda may make it unusable for the subsequent requests.
Adjust the router API to use a const reference to the lambda.
Remove mutable annotation from the routeHandler lambda because it
is not needed anymore.

Add a regression test to verify the behavior.

Task-number: QTBUG-100868
Pick-to: 6.4
Change-Id: I19f91c6a61e9155378e5ff34cbdb9b27d09fce2c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-07-22 16:26:11 +02:00
Ievgenii Meshcheriakov ee000e44fe Remove unnecessary SSL #include's
Forward-declare the used classes instead in the header and include them
in the corresponding source file.

Task-number: QTBUG-100868
Pick-to: 6.4
Change-Id: I10a288818df6cad0b089351816f0a2d0eb9c012d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-30 11:19:48 +02:00
Marc Mutz 62f94ae60f Prefer printf-style logging over std::ostream-style
Generates less code, and we may be able to remove QDebug includes.

Some uses aren't easily ported, leave them as ostream-style.

Also prefer %ls/qUtf16Printable() over %s/qPrintable() (again: less
code).

Pick-to: 6.4
Task-number: QTBUG-100868
Change-Id: I812bed2ecfeb5776155ff5f95320d6accc5974d3
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-23 22:47:54 +02:00
Lucie Gérard 57b0db0896 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I657c36f679b9448ec68d411a492171bc39df1411
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
2022-06-22 17:35:22 +02:00
Marc Mutz cb25d34789 Fix std::forward uses
- in route() implementations, the viewHandler was passed by universal
  reference, however, it was then captured either by value (copying,
  which some viewHandlers may not support) or - yuck - by reference,
  creating a dangling pointer in case a temporary was passed. This
  error was also present in the example implementations in the docs
  and the test. To fix, std::forward the viewHandler into the mutable
  lambda and std::move() it inside the lambda into
  route.bindCaptured().

- One more case of RouterHandler being passed by rvalue ref and then
  std::forward()ed, fixed by taking by value and std::move()ing
  instead.

Pick-to: 6.4
Task-number: QTBUG-100868
Change-Id: I729f7e0c8fd0838679bcefc141fd5cea333d276b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
2022-06-22 10:15:42 +02:00
Marc Mutz 6fa185164a Fix QLatin1String usage
- replace with QLatin1StringView

- take by value, not by cref

- in one case, replace with a char16_t, because size() == 1

Pick-to: 6.4
Task-number: QTBUG-100868
Change-Id: Ib1d9c3058d3dc9aad560b27bda89b7dc1f897dbb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
2022-06-22 10:15:24 +02:00
Ievgenii Meshcheriakov c9935bdb8b tst_qhttpserver: Fix code for ignoring SSL errors
Don't print expected errors. The existing code was printing all
errors at least once.

Task-number: QTBUG-100479
Change-Id: I970b9e0b59f7abd9c82f2a750017eb9739b1fd24
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-10 17:34:44 +00:00
Ievgenii Meshcheriakov 4dbe4d250a tst_qhttpserver: Don't check for OpenSSL support when ignoring errors
Always ignore the same set of errors instead. At least on macOS it
is possible to compile Qt with OpenSSL support but don't have it
at runtime.

Fixes: QTBUG-100479
Change-Id: I213de297f840e6ef344fc87317103a9766f0598b
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-10 18:34:41 +01:00
Ievgenii Meshcheriakov d20cc5623f Regenerate the test certificate/key pair
Current openssl versions do not accept secret keys shorter than
2048 by default. This causes tests with 1024 bytes key to fail.

This commit replaces the certificate/key pair with new one with
the key length of 4096 that should be good enough for some time.

Fixes: QTBUG-100479
Change-Id: I185812e867eae2c6295cb28df229785f91fc99f2
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-09 14:39:20 +01:00
Maurice Kalinowski 51734cd595 Fix build against 6.0
Fixes: QTBUG-89381
Change-Id: I79d0329f06005434c691416f92fbdac0d7252385
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
2020-12-16 19:10:36 +01:00
Mikhail Svetkin e49b9a111a Introduce QHttpServerFutureResponse
Provide simple API for asynchronous resoponses

Change-Id: Ic0c92cce95751dc8f9d6b0dfa96e39019f5f5e9e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-11 21:20:57 +02:00
Mikhail Svetkin 2a67efadf1 Don't destory socket and request objects while handling a request
Task-number: QTBUG-84617
Change-Id: Ibf98fb329c817ae39f66e539cdb30a4194cb3b42
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
2020-06-06 21:48:40 +02:00
Mikhail Svetkin e0fa374411 Add QHttpServer::afterRequest
This function allows to register a function to be run after each request.

Task-number: QTBUG-77090
Change-Id: I40dd4c1e9a447fbe034149ffc1923c7c814cf0e9
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
2020-05-14 20:36:31 +02:00
Mikhail Svetkin f28694ea2c tst_qhttpserver: Add expected warning messages
Change-Id: Iffbde346b6e8454dc9e8b19d96e8a4a4e860f1e2
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
2020-05-14 19:52:34 +02:00
Mårten Nordheim 93ff67a3fc Make QAbstractHttpServer::listen return 0 on fail
Which then makes it compatible with other listen() functions in Qt
in the sense that doing if (server.listen()) will behave
consistently.
Ports being listened to can then be gotten from the new serverPorts()
function, mirroring serverPort() from QTcpServer etc., except it's a
QVector.

This is a source incompatible change, but is allowed because this
module is still in tech preview.

Fixes: QTBUG-79411
Change-Id: I09764afbf8fd866af4f43ab90fcf9c2e9a373237
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
2020-02-18 12:17:22 +01:00
Mikhail Svetkin 7dc185f101 Refactor access to QMetaEnum for QHttpServerRequest::Method
Replace QHttpServerRequest::staticMetaObject.indexOfEnumerator("Method")
with QMetaEnum::fromType<QHttpServerRequest::Method>.

Change-Id: Idda142fd065e9ce216e2d76c09a5b19d384df1b3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-11-10 22:41:25 +01:00
Mikhail Svetkin 43a04e17a1 Allow using QHttpServerRequest/Responder at the same time
Fixes: QTBUG-77088
Change-Id: I2208cee290d086339aba705f959c57e0f6a73a87
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-10-25 08:55:01 +02:00
Sylvain Garcia f04a6809b1 HTTPS support
Added new `QAbstractHttpServer::sslSetup` which enables HTTPS usage.
Added new `QSslServer` which inherits from `QTcpServer` and configures
incoming TCP clients to use SSL.

[ChangeLog][QHttpServer][Https support] Https support added to
QAbstractHttpServer class

Change-Id: I536cf48b86b246e3f4b9d960f793b93670afe06f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Guy Poizat <gerrit.qt@gmail.com>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
2019-10-04 17:16:09 +02:00
Mikhail Svetkin 73175545e6 QHttpServerResponse: Extend the API
Add new API for HTTP headers manipulations.
Add QHttpServerResponse::write function which will
allow to write custom response objects in a future.

Fixes: QTBUG-76933
Change-Id: I744303be1b517c07f698c4a3dd2c4296f77e3b03
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@tqcs.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-10-03 19:40:22 +02:00
Mikhail Svetkin b838370769 QHttpServerResponse: Change text/html -> application/x-empty
It does not make sense to set "text/html" as content type for empty
responses.

Change-Id: I93f540c97cef38409f1479f1c332349155edd176
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io>
2019-08-22 06:38:26 +02:00
Mikhail Svetkin f46cb8832f Add QHttpServerLiterals
Currently we have a lot of duplication of most common HTTP headers and their
values.
This patch moves them to one place.

Change-Id: Idf9ddc5164e81649b4cc37ed92a516eb1eedab3a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io>
2019-08-21 22:07:26 +02:00
Mikhail Svetkin 055d36692b QHttpServerResponder: refactor and extend the API
Currently QHttpServerResponder is not flexible enough:
 - Does not allow to rewrite headers
 - Does not allow to write headers without storing them internaly first
 - Does not provide API to make your own HTTP response

This patch will help to implement QHttpServerResponse
setHeaders/addHeaders

Change-Id: If9e21f7f7a58629bfedad0f10cab67d67fce0a89
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-08-20 18:40:26 +02:00
Mikhail Svetkin b63b0862c9 QHttpServerResponse: add ctor for QJsonArray
Task-number: QTBUG-76619
Change-Id: Ibce12e33754e950f467c8fb291d447cfc0694062
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-07-11 21:56:24 +02:00
Mikhail Svetkin a8777eb51e QHttpServerResponse: use compact mode for json objects
Change-Id: Ia01f2f9a1483b326bc92eda20045f9764616cf66
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-07-11 20:10:31 +02:00
Tasuku Suzuki fc7908e628 Introduce QHttpServerResponse::fromFile()
This is a shortcut for static file contents.

Change-Id: I54d97c60822e661c1405f27ea8d4598f0363b144
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-06-14 15:19:29 +09:00