Changeset 867

Show
Ignore:
Timestamp:
2008-03-09 01:29:48 (9 months ago)
Author:
MaierMan
Message:

#190: Allow to get (some) POST data
Alright, as there is no way to get the channel (and therefore the post data) from unknownContentType.xul we have to watch all http requests and "cache" the post-data.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome/content/dta/manager.js

    r862 r867  
    6161const BinaryInputStream = Construct('@mozilla.org/binaryinputstream;1', 'nsIBinaryInputStream', 'setInputStream'); 
    6262const FileInputStream = Construct('@mozilla.org/network/file-input-stream;1', 'nsIFileInputStream', 'init'); 
    63  
     63const StringInputStream = Construct('@mozilla.org/io/string-input-stream;1', 'nsIStringInputStream', 'setData'); 
     64 
     65const ContentHandling = Serv('@downthemall.net/contenthandling;1', 'dtaIContentHandling'); 
    6466const MimeService = Serv('@mozilla.org/uriloader/external-helper-app-service;1', 'nsIMIMEService'); 
    6567const ObserverService = Serv('@mozilla.org/observer-service;1', 'nsIObserverService'); 
     
    900902        }, 
    901903         
     904        postData: null, 
     905         
    902906        _fileName: null, 
    903907        get fileName() { 
     
    16171621                [ 
    16181622                        'fileName', 
     1623                        'postData', 
    16191624                        'numIstance', 
    16201625                        'description', 
     
    18651870        } 
    18661871        try { 
    1867                 var http = this._chan.QueryInterface(Ci.nsIHttpChannel); 
     1872                let http = this._chan.QueryInterface(Ci.nsIHttpChannel); 
    18681873                if (c.start + c.written > 0) { 
    18691874                        http.setRequestHeader('Range', 'bytes=' + (c.start + c.written) + "-", false); 
     
    18741879                http.setRequestHeader('Keep-Alive', '', false); 
    18751880                http.setRequestHeader('Connection', 'close', false); 
     1881                if (d.postData) { 
     1882                        let uc = http.QueryInterface(Ci.nsIUploadChannel); 
     1883                        uc.setUploadStream(new StringInputStream(d.postData, d.postData.length), null, -1); 
     1884                        http.requestMethod = 'POST'; 
     1885                }                         
    18761886        } 
    18771887        catch (ex) { 
    1878  
     1888                Debug.log("error setting up channel", ex); 
     1889                // no-op 
    18791890        } 
    18801891        this.c.running = true; 
     
    24952506                        d.hash = null; // to initialize prettyHash  
    24962507                } 
     2508                try { 
     2509                        d.postData = ContentHandling.getPostDataFor(d.urlManager.url.toURI()); 
     2510                } 
     2511                catch (ex) { 
     2512                        Debug.log("No post data for me: " + d.urlManager.url, ex); 
     2513                        // no-op 
     2514                } 
    24972515                d.state = start ? QUEUED : PAUSED; 
    24982516                if (d.is(QUEUED)) { 
  • trunk/chrome/content/dta/manager/sessionmanager.js

    r795 r867  
    255255                                        'conflicts', 
    256256                                        'fileName', 
     257                                        'postData', 
    257258                                        'destinationName', 
    258259                                        'resumable',