<commit_before>var fs = require('fs'),
  https = require('https'),
  redis = require('redis').createClient(),
  http = require('http'),
  url = require('url')

var statics = {
  '/index.html':'text/html',
  '/cb.html':'text/html',
  '/base64.js':'application/javascript',
  '/config.js':'application/javascript',
  '/davStorage.js':'application/javascript',
  '/jquery-1.6.1.min.js':'application/javascript',
  '/sjcl.js':'application/javascript',
  '/syncStorage.js':'application/javascript',
  '/webfinger.js':'application/javascript',
  '/myfavouritesandwich.appcache':'text/cache-manifest',
  '/favicon.ico':'image/x-icon',
  '/css/uncompressed/reset.css':'text/css',
  '/css/uncompressed/text.css':'text/css',
  '/css/uncompressed/layout.css':'text/css',
  '/css/uncompressed/general.css':'text/css',
  '/css/uncompressed/img/plate.png':'image/png',
  '/css/uncompressed/img/myfavouritesandwich.png':'image/png',
  '/css/uncompressed/img/island.png':'image/png',
  '/css/uncompressed/img/footerback.png':'image/png',
  '/css/uncompressed/img/change.png':'image/png',
  '/css/uncompressed/img/changehover.png':'image/png'
}

var credentials = (function() {
  return {
    check: function(req) {
      return true
    }
  }
})()

var webdav = (function() {
  return {
    handle: function(req, res) {
      if(req.method == 'GET') {
        redis.get('storage_'+req.path, function(err, data) {
          if(data) {
            res.writeHead(200, {'Access-Control-Allow-Origin': '*'})
            res.end(data)
          } else {
            res.writeHead(404, {'Access-Control-Allow-Origin': '*'})
            res.end()
          }
        })
      } else if(req.method == 'OPTIONS') {
        res.writeHead(200, {
          'Access-Control-Allow-Origin': req.headers.Origin,
          'Access-Control-Allow-Methods': 'GET, PUT, DELETE, OPTIONS',
          'Access-Control-Allow-Credentials': true,
          'Access-Control-Allow-Headers': 'Authorization'
          })
        res.end()
      } else if(req.method == 'PUT') {
        if(credentials.check(req)) {
          redis.put('storage_'+req.path, function(err, data) {
            res.writeHead(204, {
              'Access-Control-Allow-Origin': req.headers.Origin,
            })
            res.end(data)
          })
        } else {
          res.writeHead(401, {
            'Access-Control-Allow-Origin': req.headers.Origin,
          })
          res.end(data)
        }
      } else if(req.method == 'DELETE') {
        if(credentials.check(req)) {
          redis.delete('storage_'+req.path, function(err, data) {
            res.writeHead(204, {
              'Access-Control-Allow-Origin': req.headers.Origin,
            })
            res.end(data)
          })
        } else {
          res.writeHead(401, {
            'Access-Control-Allow-Origin': req.headers.Origin,
          })
          res.end(data)
        }
      }
            
    }
  }
})()

wallet = (function() {
  return {
    handle: function(req, res) {
      res.writeHead(200, {
        'Access-Control-Origin-Allow': '*'
      })
      res.end(
        JSON.stringify({
          'userAddress': '<EMAIL>',
          'storageType': 'http://unhosted.org/spec/dav/0.1',
          'davUrl': 'https://myfavouritesandwich.org/',
          'davToken': 'abcd',
          'cryptoPwd': '<PASSWORD>'
        })
      )
    }
  }
})()

https.createServer({
  ca:fs.readFileSync('/root/sub.class1.server.ca.pem'),
  key:fs.readFileSync('/root/sand/ssl.key'),
  cert:fs.readFileSync('/root/sand/ssl.crt')
}, function(req	, res) {
  var path = url.parse(req.url).pathname
  if(path == '/') {
    path = '/index.html'
  }
  var contentType = statics[path]
  if(contentType) {
    console.log('200: '+path)<commit_msg>fix PUT<commit_after>var fs = require('fs'),
  https = require('https'),
  redis = require('redis').createClient(),
  http = require('http'),
  url = require('url')

var statics = {
  '/index.html':'text/html',
  '/cb.html':'text/html',
  '/base64.js':'application/javascript',
  '/config.js':'application/javascript',
  '/davStorage.js':'application/javascript',
  '/jquery-1.6.1.min.js':'application/javascript',
  '/sjcl.js':'application/javascript',
  '/syncStorage.js':'application/javascript',
  '/webfinger.js':'application/javascript',
  '/myfavouritesandwich.appcache':'text/cache-manifest',
  '/favicon.ico':'image/x-icon',
  '/css/uncompressed/reset.css':'text/css',
  '/css/uncompressed/text.css':'text/css',
  '/css/uncompressed/layout.css':'text/css',
  '/css/uncompressed/general.css':'text/css',
  '/css/uncompressed/img/plate.png':'image/png',
  '/css/uncompressed/img/myfavouritesandwich.png':'image/png',
  '/css/uncompressed/img/island.png':'image/png',
  '/css/uncompressed/img/footerback.png':'image/png',
  '/css/uncompressed/img/change.png':'image/png',
  '/css/uncompressed/img/changehover.png':'image/png'
}

var credentials = (function() {
  return {
    check: function(req) {
      return true
    }
  }
})()

var webdav = (function() {
  return {
    handle: function(req, res) {
      if(req.method == 'GET') {
        redis.get('storage_'+req.path, function(err, data) {
          if(data) {
            res.writeHead(200, {'Access-Control-Allow-Origin': '*'})
            res.end(data)
          } else {
            res.writeHead(404, {'Access-Control-Allow-Origin': '*'})
            res.end()
          }
        })
      } else if(req.method == 'OPTIONS') {
        res.writeHead(200, {
          'Access-Control-Allow-Origin': req.headers.Origin,
          'Access-Control-Allow-Methods': 'GET, PUT, DELETE, OPTIONS',
          'Access-Control-Allow-Credentials': true,
          'Access-Control-Allow-Headers': 'Authorization'
          })
        res.end()
      } else if(req.method == 'PUT') {
        if(credentials.check(req)) {
          var content = ''
          req.addListener('data', function(chunk) {
            content += chunk
          })
          req.addListener('end', function() {
            redis.set('storage_'+req.path, content, function(err, data) {
              res.writeHead(204, {
                'Access-Control-Allow-Origin': req.headers.Origin,
              })
              res.end(data)
            })
          })
        } else {
          res.writeHead(401, {
            'Access-Control-Allow-Origin': req.headers.Origin,
          })
          res.end(data)
        }
      } else if(req.method == 'DELETE') {
        if(credentials.check(req)) {
          redis.delete('storage_'+req.path, function(err, data) {
            res.writeHead(204, {
              'Access-Control-Allow-Origin': req.headers.Origin,
            })
            res.end(data)
          })
        } else {
          res.writeHead(401, {
            'Access-Control-Allow-Origin': req.headers.Origin,
          })
          res.end(data)
        }
      }
            
    }
  }
})()

wallet = (function() {
  return {
    handle: function(req, res) {
      res.writeHead(200, {
        'Access-Control-Origin-Allow': '*'
      })
      res.end(
        JSON.stringify({
          'userAddress': '<EMAIL>',
          'dataScope': 'sandwiches',
          'storageType': 'http://unhosted.org/spec/dav/0.1',
          'davUrl': 'https://myfavouritesandwich.org/',
          'davToken': '<PASSWORD>',
          'cryptoPwd': '<PASSWORD>'
        })
      )
    }
  }
})()

https.createServer({
  ca:fs.readFileSync('/root/sub.class1.server.ca.pem'),
  key:fs.readFileSync('/root/sand/ssl.key'),
  cert:fs.readFileSync('/root/sand/ssl.crt')
}, function(req	, res) {
  var path = url.parse(req.url).pathname
  if(path == '/') {
    path = '/index.html'
  }
  var contentType = statics[path]
  if(contentType) {
    console.log('200: '+path)
{'fraction_non_alphanumeric': 0.18665977249224405, 'fraction_numerical': 0.00904860392967942, 'mean_word_length': 2.2645569620253165, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '3251459', 'n_tokens_mistral': 2659, 'n_tokens_neox': 2550, 'n_words': 307}