Hi Christian, *

> Daniel Boelzle wrote:
>> do you know how to influence/set a http channel's timeout?
> 
> Channels don't necessarily have a timeout. HTTP doesn't. You could 
> cancel it off a timer (although you need to take some care to handle 
> redirects correctly).

tried that, doesn't work. The timer fires on the same thread it has been
created. So if I block the thread via nsIchannel::open()...
I tried to create the timer on a separate thread
(nsIThreadManaher::newThread), but deadlock when creating a
dispatch-proxy (on trunk only, need to mark the target object
nsIClassInfo::THREAD_SAFE). Please have a look at the attached code, any
ideas?

> 
>> Even some documented prefs [1] don't seem to work (at
>> least not in Thunderbird).
> 
> I don't see a pref for an HTTP channel's timeout there... Only for 
> timeout when connecting and for keep-alive, and I'm not sure the first 
> one works.

"network.http.request.timeout" in that doc

thanks for comments,
-Daniel

================================

    g_timerEventTarget = getThreadManager().newThread(0)
    ...

    var timer;
    var runnable = getProxyObjectManager().getProxyForObject(
        g_timerEventTarget, Components.interfaces.nsIRunnable,
        {   // nsISupports:
            m_ifaces: [ Components.interfaces.nsIRunnable,
                        Components.interfaces.nsIClassInfo,
                        Components.interfaces.nsISupports ],
            QueryInterface: function(iid) {
                for each ( var iface in this.m_ifaces ) {
                    if (iid.equals( iface ))
                        return this;
                }
                throw Components.results.NS_ERROR_NO_INTERFACE;
            },
            // xxx todo: discuss tagging this object to be
            flags: Components.interfaces.nsIClassInfo.THREADSAFE,
            implementationLanguage:
            Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
            getHelperForLanguage: function( language ) { return null; },
            getInterfaces: function( count ) {
                count.value = this.m_ifaces.length;
                return this.m_ifaces;
            },
            // nsIRunnable:
            run: function() {
                // timer will be fired on same thread as timer creation:
                timer = Components.classes["@mozilla.org/timer;1"]
                        .createInstance(Components.interfaces.nsITimer);
                timer.initWithCallback(
                    { // nsITimerCallback:
                        notify: function( timer_ ) {
                                    channel.cancel(NS_BINDING_FAILED);
                                }
                    },
                    delaySecs * 1000,
                    Components.interfaces.nsITimer.TYPE_ONE_SHOT );
            }
        }, Components.interfaces.nsIProxyObjectManager.INVOKE_SYNC );
// ==== never reach this ====
    runnable.run();


    ...
    var stream = channel.open();
    timer.cancel();
_______________________________________________
dev-tech-network mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-network

Reply via email to