[Qt-interest] Fwd: Subclass QNetworkRequest

Jason Wood jwood275 at googlemail.com
Tue Feb 23 10:08:06 CET 2010


Hi Thiago,

On Tue, Feb 23, 2010 at 7:27 AM, Thiago Macieira <thiago at kde.org> wrote:

> Em Segunda-feira 22. Fevereiro 2010, às 23.20.14, Jason Wood escreveu:
> > Hi,
> >
> > Is it possible to subclass QNetworkRequest to throttle outgoing data?
>
> No.
>
> It's possible to subclass QNetworkRequest, but it won't do you any good. It
> doesn't contain any data.
>
> Did you mean subclassing QNetworkReply?
>
> Does QNetworkReply contain the outgoing data? I noticed that QNetworkReply
was a QIODevice but I thought that would be for the data coming back rather
than the request body. If it is possible to throttle outgoing data by
subclassing QNetworkReply, would that be a better approach than the method
I'm currently using with the QIODevice?


> > It
> > doesn't seem to implement QIODevice so I'm not exactly sure how I could
> do
> > it, does anyone have any ideas? I was originally using a throttled
> > QIODevice as the data in the QNetworkAccessManager::post() method which
> is
> > OK in Windows but OSX seems to have a much larger buffer size and so
> > buffering to low speed (~5kB/s) causes the connection to timeout because
> > the data is not sent until the internal buffer is full. Please correct me
> > if I'm wrong but that does seem to be the case from my testing.
>
> Your approach is correct.
>
> Your QIODevice must emit readyRead() and supply with enough data to keep
> the
> transfer rate limited. There should be no buffering effects on sending
> data, so
> if you have a testcase showing it failing on Mac, we'll be interested.
>
>
OK, perhaps that's where my problem lies, I do not emit readyRead() at all,
I just calculate the number of bytes required to maintain a constant
throttled speed and return only those bytes in readData() but readData() is
constantly called without ever emitting readyRead() so how would that make a
difference?

In response to Markus:

I am returning both the correct size for size() and false for isSequential()
in my QIODevice as well as setting the content-length header explicitly in
the request.

Thanks,

Jason


> --
>
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>  Senior Product Manager - Nokia, Qt Development Frameworks
>      PGP/GPG: 0x6EF45358; fingerprint:
>      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100223/553f6e86/attachment.html 


More information about the Qt-interest-old mailing list