[Development] Does QNetworkAccessManager could provide the Server Sent Event feature ?

Paul Chavent paul.chavent at fnac.net
Thu Feb 19 19:54:34 CET 2015

On 02/17/2015 10:17 PM, Thiago Macieira wrote:
> On Tuesday 17 February 2015 20:50:44 Paul Chavent wrote:
>> On 02/16/2015 11:58 PM, Thiago Macieira wrote:
>>> On Monday 16 February 2015 23:52:19 Paul Chavent wrote:
>>>> The parts 6 "Parsing an event stream" [2] gives the specs of the format
>>>> over http. The part 7 "Interpreting an event stream" explains how it
>>>> should be handled by the client. For some sample code, I've found useful
>>>> those two pages [3] and [4].
>>>> [2] http://www.w3.org/TR/eventsource/#parsing-an-event-stream
>>>> [3]
>>>> https://today.java.net/article/2010/03/31/html5-server-push-technologies-> >> pa
>>>> rt-1#sse [4] http://www.html5rocks.com/en/tutorials/eventsource/basics/
>>> I'm looking for the HTTP command verb and expected replies.
>>> If it's a GET, POST, PUT, DELETE or similar, with the reply a 200 Ok, then
>>> QNAM already supports this and no modifications are necessary.
>> The difference is that the server can send asynchronous responses (event). I
>> will look deeper in the current code base.
> If it's plain HTTP/1.x, then the server cannot send anything that the client
> did not ask for (HTTP/2.0 can do that). The only way to implement server-
> pushed data in HTTP/1.x is for the client to make a request that the server
> always responds with a Chunked transfer that never ends. That's how 1990s web-
> based chats were implemented.
> If that's ow this server event is implemented, then QNAM already supports it.
> The QNetworkReply's readyRead() signal will be emitted whenever new events are
> received. You just have to parse it.
> At most, we'd implement a wrapper around QNetworkReply to make the parsing
> easier.
> If it's not how it's implemented -- if there are HTTP spec changes -- then
> QNAM needs modifications.

Thank you for pointing this alternative.

Indeed, I'm not sure that this specification (SSE) require a minimal HTTP version in order to work.

The advantage of SSE over chunks would be the availability of an event framework.

More information about the Development mailing list