<commit_before>"use strict";
var http = require('http')
  , express = require('express')
  , path = require('path')
  , logger = require('./logger').get('appium')
  , appium = require('./app/appium')
  , parser = require('./app/parser');

var main = function(args, readyCb, doneCb) {
  var rest = express()
    , server = http.createServer(rest);
  if (typeof doneCb === "undefined") {
    doneCb = function() {};
  }
  // in case we'll support blackberry at some point
  args.device = 'iOS';

  rest.configure(function() {
    var bodyParser = express.bodyParser()
      , parserWrap = function(req, res, next) {
          // wd.js sends us http POSTs with empty body which will make bodyParser fail.
          if (parseInt(req.get('content-length'), 10) <= 0) {
            return next();
          }
          bodyParser(req, res, next);
        };

    rest.use(express.favicon());
    rest.use(express.static(path.join(__dirname, '/app/static')));
    if (args.verbose) {
      rest.use(express.logger('dev'));
    }
    rest.use(parserWrap);
    rest.use(express.methodOverride());
    rest.use(rest.router);
  });
  // Instantiate the appium instance
  var appiumServer = appium(args);
  // Hook up REST http interface
  appiumServer.attachTo(rest);
  // Start the web server that receives all the commands
  server.listen(args.port, args.address, function() {
    var logMessage = "Appium REST http interface listener started on "+args.address+":"+args.port;
    logger.info(logMessage.cyan);<commit_msg>better handling of content-length variations<commit_after>"use strict";
var http = require('http')
  , express = require('express')
  , path = require('path')
  , logger = require('./logger').get('appium')
  , appium = require('./app/appium')
  , parser = require('./app/parser');

var main = function(args, readyCb, doneCb) {
  var rest = express()
    , server = http.createServer(rest);
  if (typeof doneCb === "undefined") {
    doneCb = function() {};
  }
  // in case we'll support blackberry at some point
  args.device = 'iOS';

  rest.configure(function() {
    var bodyParser = express.bodyParser()
      , parserWrap = function(req, res, next) {
          // wd.js sends us http POSTs with empty body which will make bodyParser fail.
          var cLen = req.get('content-length');
          if (typeof cLen === "undefined" || parseInt(cLen, 10) <= 0) {
            req.headers['content-length'] = 0;
            next();
          } else {
            bodyParser(req, res, next);
          }
        };

    rest.use(function(req, res, next) {
      next();
    });
    rest.use(express.favicon());
    rest.use(express.static(path.join(__dirname, '/app/static')));
    if (args.verbose) {
      rest.use(express.logger('dev'));
    }
    rest.use(parserWrap);
    rest.use(express.methodOverride());
    rest.use(rest.router);
  });
  // Instantiate the appium instance
  var appiumServer = appium(args);
  // Hook up REST http interface
  appiumServer.attachTo(rest);
  // Start the web server that receives all the commands
  server.listen(args.port, args.address, function() {
    var logMessage = "Appium REST http interface listener started on "+args.address+":"+args.port;
    logger.info(logMessage.cyan);
{'fraction_non_alphanumeric': 0.1542027194066749, 'fraction_numerical': 0.0021631644004944375, 'mean_word_length': 3.0012360939431395, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '4952710', 'n_tokens_mistral': 999, 'n_tokens_neox': 974, 'n_words': 247}