Can't abort a createInputStream

I'm trying to cancel a createInputStream using the OpenStreamProgressCallback.
I was expecting that returning false from OpenStreamProgressCallback would abort, but it does not work.
actually, the returned value of the callback is never checked in URLConnectionState::start() (i just checked on Mac)

Shouldn't it be changed to something like that ? Or isn't it made for that?

    bool start (URL::OpenStreamProgressCallback* callback, void* context)

        while (isThreadRunning() && ! initialised)
            if (callback != nullptr)
                if (! callback (context, latestTotalBytes, (int) [[request HTTPBody] length]))

            Thread::sleep (1);

        return connection != nil && ! hasFailed;

To clarify, I was expecting that returning false from the callback would abort the createInputStream() because of that comment in the doc :

   /** This callback function can be used by the createInputStream() method.
       It allows your app to receive progress updates during a lengthy POST operation. If you
        want to continue the operation, this should return true, or false to abort.
    typedef bool (OpenStreamProgressCallback) (void* context, int bytesSent, int totalBytes);

I'm in a case where I want to abort the createInputStream from the callback before it ends because my threadShouldExit()

Any chance to get this possibility to abort a createInputString with the OpenStreamProgressCallback working?
or am I having a wrong approach and misinterpreting the use of OpenStreamProgressCallback??

Sorry, yes, that is how it's supposed to work, and it's just on OSX where it doesn't (because of the way OSX handles this stuff internally).

But the current OSX implementation uses some deprecated APIs, and I've got a half-finished re-implementation of it in the works. When that's finished, I'll check that this works, but until then there's no point in us trying to fix the current code.

1 Like

ok, I understand, but if you don't add a workaround, please write in the documentation that this does not work. it's a pity that we are loosing some time encountering "known bugs"

Sorry, didn't know it was broken!

Is that bug still there? any plan to fix it or approximate date for the new implementation release?

Sorry, yes, it's still in our backlog. Will get onto it when poss..

I’m a bit sad this bug hasn’t been fixed in the last ‘releases’.
how far away is that in the backlog now? :slight_smile:

Yeah, sorry, this one kept getting bounced… I have a branch with a half-finished implementation that I keep meaning to go back to and finish…

Sorry to come back to this, but the bug is there since 4 months, so again, if you don’t add a workaround, why not adding a warning in the documentation saying that this does not work/is not implemented ?

Is the solution I posted in the first post (adding the check of the value returned by the callback) that terrible?

any news? :slight_smile:

We released the updated version using the new APIs a while ago, IIRC.

But it seems you still do not check the return value of the callback ?

So, can’t you check the value returned by the callback?
Sorry for being pushy, but it’s been almost 6 months now…

Yes, sorry we didn’t spot that one - will get it sorted out today!

1 Like