Changeset 38252

Show
Ignore:
Timestamp:
08/12/10 13:02:39 (3 years ago)
Author:
anekos
Message:

Proxy 対応

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/vimperator-plugins/trunk/twittperator.js

    r38251 r38252  
    2929  <description>Twitter Client using ChirpStream</description> 
    3030  <description lang="ja">OAuth対応Twitterクライアント</description> 
    31   <version>1.0.12</version> 
     31  <version>1.1.0</version> 
    3232  <minVersion>2.3</minVersion> 
    3333  <maxVersion>2.4</maxVersion> 
     
    12041204      startTime = new Date(); 
    12051205 
     1206      let useProxy = !!setting.proxyHost; 
    12061207      let host = "chirpstream.twitter.com"; 
    12071208      let path = "/2b/user.json"; 
     1209      let authHeader = tw.getAuthorizationHeader("http://" + host + path); 
     1210 
     1211      if (useProxy) 
     1212        path = "http://" + host + path; 
    12081213 
    12091214      let get = [ 
    1210         "GET " + path + " HTTP/1.1", 
     1215        "GET " + path + " HTTP/1.0", 
    12111216        "Host: " + host, 
    1212         "Authorization: " + tw.getAuthorizationHeader("http://" + host + path), 
     1217        "Authorization: " + authHeader, 
    12131218        "", 
    12141219        "" 
     
    12201225            svc.QueryInterface(Ci["nsISocketTransportService"]); 
    12211226 
    1222       let transport = socketService.createTransport(null, 0, host, 80, null); 
     1227      let transport = 
     1228        socketService.createTransport( 
     1229          null, 0, 
     1230          useProxy ? setting.proxyHost : host, 
     1231          useProxy ? parseInt(setting.proxyPort || '3128', 10) : 80, 
     1232          null); 
    12231233      let os = transport.openOutputStream(0, 0, 0); 
    12241234      let is = transport.openInputStream(0, 0, 0); 
     
    12451255          let data = sis.read(len); 
    12461256          let lines = data.split(/\r\n|[\r\n]/); 
    1247           if (lines.length > 2) { 
     1257          if (lines.length >= 2) { 
    12481258            lines[0] = buf + lines[0]; 
    12491259            for (let [, line] in Iterator(lines.slice(0, -1))) { 
    12501260              try { 
    1251                 liberator.log(line); 
    1252                 onMsg(Util.fixStatusObject(JSON.parse(line)), line); 
     1261                if (/^\s*\{/(line)) 
     1262                  onMsg(Util.fixStatusObject(JSON.parse(line)), line); 
    12531263              } catch (e) { liberator.log(e); } 
    12541264            } 
     
    16141624        action: function(arg) { 
    16151625          if (arg.match(/^.+/)) { 
    1616             showFollowersStatus(arg, true); 
     1626            Twittperator.showFollowersStatus(arg, true); 
    16171627          } else { 
    16181628            Twittperator.showTwitterMentions(); 
     
    17231733 
    17241734        if (!arg) 
    1725           return showFollowersStatus(null, args.bang); 
     1735          return Twittperator.showFollowersStatus(null, args.bang); 
    17261736 
    17271737        if (args.bang) { 
     
    17311741        } else { 
    17321742          if (arg.length === 0) 
    1733             showFollowersStatus(); 
     1743            Twittperator.showFollowersStatus(); 
    17341744          else 
    17351745            Twitter.say(arg); 
     
    17941804      historyLimit: let (v = gv.twittperator_history_limit) (v === 0 ? 0 : (v || 1000)), 
    17951805      showTLURLScheme: let (v = gv.twittperator_show_tl_with_https_url) ("http" + (v === false ? "" : "s")), 
     1806      proxyHost: gv.twittperator_proxy_host, 
     1807      proxyPort: gv.twittperator_proxy_port, 
    17961808    }); 
    17971809