<commit_before>var http = require('http')
  , https = require('https');

  //////////////
 // test app //
//////////////

http.createServer(function (req, res) {
  res.writeHead(200);
  res.end
    ( '<html>\n'
    + '<script>\n'
    + 'function testPut() {\n'
    + '  var token = window.location.hash.substring(15, 74);\n'
    + '  var xhr = new XMLHttpRequest();\n'
    + '  xhr.open(\'PUT\', \'http://myfavouritesandwich.org:9002/\', true);\n'
    + '  xhr.onreadystatechange=function() {\n'
    + '    if(xhr.status=200) {\n'
    + '      \n'
    + '      \n'
    + '      \n'
    + '    }\n'
    + '  };\n'
    + '  xhr.setRequestheader(\'Authorization: Bearer \'+token);\n'
    + '  xhr.send(\'blabla\');\n'
    + '}\n'
    + '</script>\n'
    + '<a onclick="testPut();">test PUT</a>\n'
    + '<a href="'
    + 'https://accounts.google.com/o/oauth2/auth?'
    + 'client_id=709507725318-4h<EMAIL>&'
    + 'redirect_uri=http://myfavouritesandwich.org:9000/&'
    + 'scope=http://docs.google.com/feeds/&'
    + 'response_type=token'
    + '">click</a>\n'
    + '</html>\n);
}).listen(9000);

  ////////////////////////////////
 // gdata-remoteStorage bridge //
////////////////////////////////

http.createServer(function (req, res) {
  console.log('REQ.URL:'+req.url);
  console.log('REQ.HEADERS:'+JSON.stringify(req.headers));
  var token = req.headers['authorization'];
  console.log('TOKEN:'+token);
  var options =
    { 'host': 'docs.google.com'
    , 'port': 443
    , 'method': 'POST'
    , 'path': '/feeds/default/private/full'
    , 'headers':
       { 'GData-Version': '3.0'
       , 'Authorization': 'Bearer '+token
       , 'Content-Length': '0'
       , 'Content-Type': 'text/plain'
       , 'Slug': 'LetsRide'
       , 'X-Upload-Content-Length': '30'
       , 'X-Upload-Content-Type': 'text/plain'
       }
    };
  var req2 = https.request(options, function(res2) {
    res.writeHead(200, { 'Content-Type': 'text/plain', 'Access-Control-Allow-Origin': '*'});
    res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2));
    res.write('\nSTATUS: ' + res2.statusCode);
    res.write('\nHEADERS: ' + JSON.stringify(res2.headers));
    res2.setEncoding('utf8');
    res2.on('data', function (chunk) {
      res.write('\nBODY: ' + chunk);
      res.end();
    });
  });
  req2.end();
}).listen(9002);<commit_msg>got a 201 in 2-service setup<commit_after>var http = require('http')
  , https = require('https');

  //////////////
 // test app //
//////////////

http.createServer(function (req, res) {
  console.log('WEB HIT');
  res.writeHead(200);
  res.end
    ( '<html>\n'
    + '<script>\n'
    + 'function testPut() {\n'
    + '  var token = window.location.hash.substring(14, 74);\n'
    + '  var xhr = new XMLHttpRequest();\n'
    + '  xhr.open(\'PUT\', \'http://myfavouritesandwich.org:9002/\', true);\n'
    + '  xhr.onreadystatechange=function() {\n'
    + '    if(xhr.status=200) {\n'
    + '      \n'
    + '      \n'
    + '      \n'
    + '    }\n'
    + '  };\n'
    + '  xhr.setRequestHeader(\'Authorization\', \'Bearer \'+token);\n'
    + '  xhr.send(\'blabla\');\n'
    + '}\n'
    + '</script>\n'
    + '<a href="" onclick="testPut();">test PUT</a>\n'
    + '<a href="'
    + 'https://accounts.google.com/o/oauth2/auth?'
    + 'client_id=709507725318-4h19nag3k4hv5osj1jvao0j3an3bu43t<EMAIL>&'
    + 'redirect_uri=http://myfavouritesandwich.org:9000/&'
    + 'scope=http://docs.google.com/feeds/&'
    + 'response_type=token'
    + '">click</a>\n'
    + '</html>\n');
}).listen(9000);

  ////////////////////////////////
 // gdata-remoteStorage bridge //
////////////////////////////////

http.createServer(function (req, res) {
  console.log('REQ.URL:'+req.url);
  console.log('REQ.HEADERS:'+JSON.stringify(req.headers));
  var token;
  if(req.headers['authorization']) {
    token = req.headers['authorization'].substring(7);
  } else if(req.headers['Authorization']) {
    token = req.headers['Authorization'].substring(7);
  }
  console.log('TOKEN:'+token);
  var options =
    { 'host': 'docs.google.com'
    , 'port': 443
    , 'method': 'POST'
    , 'path': '/feeds/default/private/full'
    , 'headers':
       { 'GData-Version': '3.0'
       , 'Authorization': 'Bearer '+token
       , 'Content-Length': '0'
       , 'Content-Type': 'text/plain'
       , 'Slug': 'LetsRide'
       , 'X-Upload-Content-Length': '30'
       , 'X-Upload-Content-Type': 'text/plain'
       }
    };
  var req2 = https.request(options, function(res2) {
    res.writeHead(200,
      { 'Content-Type': 'text/plain'
      , 'Access-Control-Allow-Origin': '*'
      , 'Access-Control-Allow-Methods': 'GET, PUT, DELETE'
      , 'Access-Control-Allow-Headers': 'Origin, Content-Type, Authorization'
      });
    res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2));
    res.write('\nSTATUS: ' + res2.statusCode);
    res.write('\nHEADERS: ' + JSON.stringify(res2.headers));
    res2.setEncoding('utf8');
    res2.on('data', function (chunk) {
      res.write('\nBODY: ' + chunk);
      res.end();
    });
  });
  req2.end();
  console.log(JSON.stringify(options.headers));
}).listen(9002);
{'fraction_non_alphanumeric': 0.2507221259387637, 'fraction_numerical': 0.02638166762950125, 'mean_word_length': 2.4126149802890935, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6844400', 'n_tokens_mistral': 1996, 'n_tokens_neox': 1907, 'n_words': 266}