Is there a code sample for HTTP/2 client?
-
I am trying to write a server-side application (console app, running on Linux, controlled with systemd) to send APNs push notifications from my server to iOS/MacOS apps.
Apple requires the use of HTTP/2.
Authentication, including JWT token refresh, payload formatting or any other requirements to send notifications are not a problem for me: I've done this before in C#. But now I need to do it in Qt 6, and that's where I got stuck.Is there a code sample for establishing an HTTP/2 client connection and sending a message to a server?
-
QNetworkRequest::setHttp2Configuration() before making the first request to the Apple server looks promising.
-
Additional information: as per https://developer.apple.com/documentation/usernotifications/sending-push-notifications-using-command-line-tools#Send-a-push-notification-using-a-JSON-web-token-JWT , a curl command looks like this:
curl -v
--header "apns-topic: $TOPIC"
--header "apns-push-type: alert"
--header "authorization: bearer $AUTHENTICATION_TOKEN"
--data '{"aps":{"alert":"test"}}'
--http2 https://${APNS_HOST_NAME}/3/device/${DEVICE_TOKEN}It's the "-http2 [...]" part that I am trying to figure out how to write using QNetworkAccessManager.
-
QNetworkRequest::setHttp2Configuration() before making the first request to the Apple server looks promising.
-
I read the information about available classes in the Qt docs, of course.
For example, in the method you linked to, there is the following:
"Note: HTTP/2 multiplexes several streams in a single HTTP/2 connection. This implies that QNetworkAccessManager will use the configuration found in the first request from a series of requests sent to the same host."
This raises more questions, such as: is there an example of how to start several streams on a single connection? -
-
-