GNOME Bugzilla – Bug 726348
Display download progress as we get it
Last modified: 2014-04-11 06:00:30 UTC
This is a bit hacky right now, and to really test it I need an async HTTP server via libsoup.
Created attachment 271902 [details] [review] wip/chunked-http-status
(In reply to comment #0) > This is a bit hacky right now, and to really test it I need an async > HTTP server via libsoup. I'm not sure what you mean... the code in the patch looks like it should do what you want.
Created attachment 272446 [details] [review] wip/chunked-http-status Send at just a byte at a time
(In reply to comment #2) > (In reply to comment #0) > > This is a bit hacky right now, and to really test it I need an async > > HTTP server via libsoup. > > I'm not sure what you mean... the code in the patch looks like it should do > what you want. Well it had one bug where I was not correctly accmulating an offset from the start, new patch attached. But with that fixed...if I call soup_message_unpause() early, it sends a partial result. If I only call soup_message_unpause() after I'm done writing, then I won't be writing partial bytes to the client socket.
(In reply to comment #4) > But with that fixed...if I call soup_message_unpause() early, it sends a > partial result. If I only call soup_message_unpause() after I'm done writing, > then I won't be writing partial bytes to the client socket. "Sends a partial result" meaning that it closes the connection before sending the number of bytes you'd declared in soup_message_headers_set_content_length()? The way it's supposed to work (as seen in libsoup/tests/streaming-test.c) is that if you're using Content-Length encoding (which you are), then you first explicitly set the Content-Length header (which you do), and then soup-message-io will continue to expect new chunks until you reach that length, and will just pause the message if it gets ahead of you. (If you use chunked or terminated-by-EOF encoding, you don't need to pre-declare the length, but you need to call soup_message_body_complete() to signal when you're done.) Also: libsoup's built-in Content-Range handling only works when you provide the whole response body ahead of time, so if you're streaming the result, you need to handle that yourself.
(In reply to comment #5) > "Sends a partial result" meaning that it closes the connection before sending > the number of bytes you'd declared in > soup_message_headers_set_content_length()? Ah no, this is different...I just want to write some bytes to the socket, but not the whole file. > The way it's supposed to work (as seen in libsoup/tests/streaming-test.c) is > that if you're using Content-Length encoding (which you are), then you first > explicitly set the Content-Length header (which you do), and then > soup-message-io will continue to expect new chunks until you reach that length, > and will just pause the message if it gets ahead of you. Ah. Hrm. I'll look at that, thanks. > (If you use chunked or terminated-by-EOF encoding, you don't need to > pre-declare the length, but you need to call soup_message_body_complete() to > signal when you're done.) Yeah, I don't want to do chunked (just to avoid another variable) and definitely not EOF as that would kill speed. > Also: libsoup's built-in Content-Range handling only works when you provide the > whole response body ahead of time, so if you're streaming the result, you need > to handle that yourself. Right, that's fair enough. In this case I'm not trying to mix the two, I just want a slow socket.
Decided to push this one without the test for now.