Qt web server vs mobile browsers
I have created a very simple web server in qt for special needs. As simple as we have a http request: GET / cover.png HTTP 1.1
the answer goes perfectly to desktops. when i try to get image from mobile (i tried more, but say android + opera) the image won't load. in the statement, it only downloads about 1/3 of the image, and on the side of the qt side, it claims all bytes were sent ok.
I noticed it depends on the size of the image: ~ 4k is ok, but 12k is "too much"
I know that opera on Android can load much larger images, so I have to mess up something in the answer. but at the same time, again on my desktop, all major browsers are good.
I noticed that after the image is partially loaded, the opera opens a new tcp connection for my server, but doesn't send anything! is he trying to load the image in chunks? is there such a thing in http?
I'm really lost in what's going on here ...
Update: If the file is big enough, it won't work in desktop fighter! Experienced limitations: Desktop: max. 65339 bytes Mobile phone: max. 12834 bytes
Since the limits are not the same, I don't think this is related to Qt.
source to share
I managed to figure it out: Image upload stops because the tcp connection is closed too early by my server. This is weird because I am sending responses like this:
socket->write( message );
if( !socket->waitForBytesWritten( 5000 ) )
{ puts( "Timed out!" ); }
emit sent();
This does not work. QTcpSocket is a buffered IODevice, so it should print if sending time. Maybe I am misunderstanding something about waitForBytesWritten (). So it turns out this is the Qt problem after all. If I don't delete the socket after sending it works fine. The size difference for desktop and mobile browsers is the speed they can achieve (how many bytes can get before I delete the socket).
So how can I be sure when all the bytes are actually sent to the client?
source to share