Changeset 52

Show
Ignore:
Timestamp:
04/22/06 15:44:00 (2 years ago)
Author:
atack2
Message:

Got an incorrect filename from the server

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/overhaul_headers.js

    r47 r52  
    77//* 
    88 
    9  
     9var nonsense =  { 
     10        observe: function(subject,topic,data)   { 
     11                myDump("Yep."); 
     12        } 
     13}; 
    1014 
    1115// 
     
    3135                subject = subject.QueryInterface(Components.interfaces.nsIHttpChannel); 
    3236                subject.setRequestHeader("Supports", "Overhaul 50 5000", false); 
     37                 
     38                myDump("HEY!"); 
     39                 
     40                // An observer which examines incoming responses from the 
     41                // server.  If that response indicates that we should act 
     42                // in overhaul mode, this takes the appropriate actions  
     43                // with the rest of the overhaul code. 
     44                // 
     45                // IMPLEMENTS: nsIObserver 
     46                // OBSERVES: http-on-examine-response 
     47                // 
     48                var httpResponseReader = { 
     49                        url : gURLBar.value, 
     50                 
     51                        observe: function(subject,topic,data) { 
     52                                var filename = this.url.substring(this.url.lastIndexOf('/'),  
     53                                        this.url.length);        
     54                                myDump(filename); 
     55                         
     56                                // 
     57                                // Make sure we observe the event we think we should. 
     58                                // 
     59                                if ( topic != "http-on-examine-response" ) 
     60                                        throw "OVERHAUL ERROR: Object 'httpResponseReader' was asked"  
     61                                                + " to observe an event of type: " + topic  
     62                                                + " when it only accepts type http-on-examine-response"; 
     63                         
     64                                // 
     65                                // Check for an overhaul response header 
     66                                // 
     67                                subject = subject.QueryInterface(Components.interfaces.nsIHttpChannel); 
     68                                try     { 
     69                                        var hosts_header = subject.getResponseHeader("Overhaul-hosts"); 
     70                                } 
     71                                catch( e )      { 
     72                                        myDump("Server did not request Overhaul."); 
     73                                        return; 
     74                                } 
     75                                 
     76                                // 
     77                                // Organize Information and Instantiate a Handler 
     78                                // 
     79                                myDump("Entering Overhaul mode..."); 
     80                                 
     81                                var md5_header = subject.getResponseHeader("Overhaul-md5sum"); 
     82                                var md5_list = parse_md5s(md5_header); 
     83                                 
     84                                var chunks_header = subject.getResponseHeader("Overhaul-chunk"); 
     85                                var chunks_held = parse_chunks_held(chunks_header, md5_header.length); 
     86                                 
     87                                var hosts = parse_hosts(hosts_header); 
     88                                 
     89                                var thisHandler = new overhaul_handler(hosts.ipStringList, 
     90                                        hosts.portStringList, url, filename, chunks_held, md5_list); 
     91                        } 
     92                }; 
     93                 
     94                myDump("Howdy!"); 
     95                 
     96                // 
     97                // Register the observer 
     98                // 
     99                var observerService = Components.classes["@mozilla.org/observer-service;1"] 
     100                                .getService(Components.interfaces.nsIObserverService); 
     101                observerService.addObserver(nonsense,  
     102                                "http-on-examine-response", false); 
     103                                 
     104                                observerService.addObserver(httpResponseReader,  
     105                                "http-on-examine-response", false); 
    33106        } 
    34107} 
    35  
    36  
    37  
    38 // 
    39 // An observer which examines incoming responses from the 
    40 // server.  If that response indicates that we should act 
    41 // in overhaul mode, this takes the appropriate actions  
    42 // with the rest of the overhaul code. 
    43 // 
    44 // IMPLEMENTS: nsIObserver 
    45 // OBSERVES: http-on-examine-response 
    46 // 
    47 var httpResponseReader = { 
    48         observe: function(subject,topic,data) { 
    49                 // 
    50                 // Make sure we observe the event we think we should. 
    51                 // 
    52                 if ( topic != "http-on-examine-response" ) 
    53                         throw "OVERHAUL ERROR: Object 'httpResponseReader' was asked"  
    54                                 + " to observe an event of type: " + topic  
    55                                 + " when it only accepts type http-on-examine-response"; 
    56          
    57                 // 
    58                 // Check for an overhaul response header 
    59                 // 
    60                 subject = subject.QueryInterface(Components.interfaces.nsIHttpChannel); 
    61                 try     { 
    62                         var hosts_header = subject.getResponseHeader("Overhaul-hosts"); 
    63                 } 
    64                 catch( e )      { 
    65                         myDump("Server did not request Overhaul."); 
    66                         return; 
    67                 } 
    68                  
    69                 // 
    70                 // Organize Information and Instantiate a Handler 
    71                 // 
    72                 myDump("Entering Overhaul mode..."); 
    73                  
    74                 var md5_header = subject.getResponseHeader("Overhaul-md5sum"); 
    75                 var md5_list = parse_md5s(md5_header); 
    76                  
    77                 var chunks_header = subject.getResponseHeader("Overhaul-chunk"); 
    78                 var chunks_held = parse_chunks_held(chunks_header, md5_header.length); 
    79                  
    80                 var hosts = parse_hosts(hosts_header); 
    81                  
    82                 var thisHandler = new overhaul_handler(hosts.ipStringList, 
    83                         hosts.portStringList, null, chunks_held, md5_list); 
    84         } 
    85 }; 
    86108 
    87109 
     
    103125observerService.addObserver(httpRequestInjector, "http-on-modify-request",  
    104126        false); 
    105 observerService.addObserver(httpResponseReader, "http-on-examine-response",  
    106         false); 
  • trunk/overlays.xul

    r51 r52  
    77        <script src="parse_chunks_held.js" /> 
    88        <script src="parse_md5s.js" /> 
    9         <script src="overhaul_info.js /> 
    10         <script src="overhaul_handler.js /> 
     9        <script src="overhaul_info.js" /> 
     10        <script src="overhaul_handler.js" /> 
    1111        <script src="overhaul_headers.js" /> 
    1212</overlay>