Changeset 8359


Ignore:
Timestamp:
May 8, 2009, 3:02:22 PM (14 years ago)
Author:
charles
Message:

part two of r8358. patch by kjg

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/javascript/transmission.remote.js

    r8353 r8359  
    3636                this._controller = controller;
    3737                this._error = '';
     38                this._token = '';
    3839        },
    3940
    4041        /*
    4142         * Display an error if an ajax request fails, and stop sending requests
     43         * or on a 409, globally set the X-Transmission-Session-Id and resend
    4244         */
    43         ajaxError: function(request, error_string, exception) {
     45        ajaxError: function(request, error_string, exception, ajaxObject) {
    4446                remote = this;
     47
     48                // set the Transmission-Session-Id on a 409
     49                if(request.status == 409 && (token = request.getResponseHeader('X-Transmission-Session-Id'))){
     50                        remote._token = token;
     51                        $.ajax(ajaxObject);
     52                        return;
     53                }
     54
    4555                remote._error = request.responseText
    4656                                        ? request.responseText.trim().replace(/(<([^>]+)>)/ig,"")
     
    5767                remote._controller.togglePeriodicRefresh(false);
    5868        },
    59        
     69
     70        appendSessionId: function(XHR) {
     71                XHR.setRequestHeader('X-Transmission-Session-Id', this._token);
     72        },
     73
    6074        sendRequest: function( data, success ) {
    6175                remote = this;
     
    6781                        cache: false,
    6882                        data: $.toJSON(data),
    69                         error: function(request, error_string, exception){ remote.ajaxError(request, error_string, exception) },
     83                        beforeSend: function(XHR){ remote.appendSessionId(XHR) },
     84                        error: function(request, error_string, exception){ remote.ajaxError(request, error_string, exception, this) },
    7085                        success: success
    7186                } );
Note: See TracChangeset for help on using the changeset viewer.