[Qt-interest] QHttp upload won't stream?
Jason H
scorp1us at yahoo.com
Wed Oct 7 16:18:15 CEST 2009
Flush should only be called at the end of the transfer, I don't know the internals of SSL, but I doubt it is written to handle partial blocks mid-stream.
I've numbered your steps below. I don't know why you'd have to construct a second header in 4. (Are you doing MIME?)
Given a POST is:
'''
POST /path/script.cgi HTTP/1.0
From: frog at jmarshall.com
User-Agent: HTTPTool/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 32
home=Cosby&favorite+flavor=flies
'''
You should send one header in 2.
then have a loop of
MySslSocket::write(data)
while (bytesSent<data.length())
{
thisChunkLength=qMin(data.length()-bytesSent, 4096)
sslSocket.write(data.mid(bytesSent, thisChunkLength)
bytesSent+=thisChunkLength()
emit bytesWritten(bytesSent)
}
It seems that you'll need to subclass QSslSocket to provide a proper bytesWritten implementation, based loosely on the code above, maintaining your own count. Sorry for my bad advice before. I looked at my app and it seems I never implemented a progressBar and https at the same time!
________________________________
From: Info <info at misafe.com>
To: Jason H <scorp1us at yahoo.com>
Cc: qt-interest at trolltech.com
Sent: Wed, October 7, 2009 9:54:42 AM
Subject: Re: [Qt-interest] QHttp upload won't stream?
I've taken your advise and started writing a test using QSslSocket and handling it myself. I am running into the same problem though so perhaps I am doing something wrong...
1 I startup a connection using QSslSocket::connectToHostEncrpyted()
2 When the encrypted() signal is fired, I send my HTTP request headers
3 I read in the data in the readyRead() slot until I have the header and all following data for the response.
4 I then construct a new header to send the POST data to the server and send that.
5 When the bytesWritten() signal is fired, I send the next block of data using QSslSocket::write()
The problem I'm having is that I get exactly the same behaviour as before, the data all gets sent immediately (obviously being buffered by QSslSocket) and my progress jumps right to the end as before. Is there something I should be doing differently here?
I have tried adding a flush() after the write() but that stops transmission all together.
Thanks.
On 7 Oct 2009, at 00:35, Jason H wrote:
You have to scan for the \r\n\r\n and feed everything up to the first \r\n that to QHttpRequestHeader, then you have to parse the data this means, if you have base64 content encoding or chuncked encoding you have to account for that. Be aware that the layering works out to be that SSL is first (and should be relatively transparent to you, then chunking, then base64, if applied. I used a QIODevice to do the base64 decoding, and manually parsed the content.
>
>I was writing a server though.
>
>
>
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Qt-interest-old
mailing list